GenericDAO
/**
* 所有DAO都共享的CRUD(create, read, update, delete) 基本数据访问操作的定义
*/
public interface GenericDAO<T, ID extends Serializable,E extends Exception> {
/**根据ID查询唯一对象*/
T findById(ID id) throws E;
/** 查询所有对象 */
List<T> searchAll() throws E;
/** 条件查询*/
List<T> search(T condition) throws E;
/**
* 插入或修改
*/
public void save(T entity) throws E;
/**删除*/
void delete(ID id) throws E;
void deleteBat(ID[] ids) throws E;
}
IEmpDao
public interface IEmpDao extends GenericDAO<Employee, Integer,SQLException> {
}
EmpDao,//在方法体里面写上自己的具体方法实现即可!
public class EmpDao implements IEmpDao {
public void delete(Integer id) throws SQLException {
}
public void deleteBat(Integer[] id) throws SQLException {
}
public Employee findById(Integer id) throws SQLException {
return null;
}
public void save(Employee entity) throws SQLException {
}
public List<Employee> search(Employee condition) throws SQLException {
return null;
}
public List<Employee> searchAll() throws SQLException {
return null;
}
}