从Hibernate范型DAO设计打造的自用DAO
几天前拜读了rainlife大哥哥的文章:
于是乎自行改造了项目中的原有抽象结构:
范型DAO将所有DAO的CRUD方法使用范型抽象到此层面。
public interface IGenericDAO<t></t> {
public List<t></t> find(String sql) throws NullSqlStringException,
UnformatSelectStringException,AccessDataException;
public T save(T t) throws NullPointerException,AccessDataException;
public int deleteById(String id) throws AccessDataException;
public T update(T t) throws NullPointerException,AccessDataException;
public T getById(String id) throws AccessDataException;
} 此DAO层接口主要处理针对某一PO的特殊操作的方法。
public interface ISysUserDao<sysuser></sysuser> extends IGenericDAO<sysuser></sysuser> {
public void initializeRoles(SysUser user) throws NullPointerException;
public void initializeOrganization(SysUser user) throws NullPointerException;
public void initializeHeadShip(SysUser user) throws NullPointerException;
public void initializePosition(SysUser user) throws NullPointerException;
public void initializeTitle(SysUser user) throws NullPointerException;
public void initializeWorkGroups(SysUser user) throws NullPointerException;
} 其实,范型的真实类型已经在这一层上体现了,我们使用范型主要还是为了减少在此层接口中大量出现的相同的CRUD的方法的定义。
相关推荐
dongxurr 2020-08-08
园搬家测试账号 2020-06-12
技术之博大精深 2020-06-10
snowphy 2020-05-12
snowguy 2020-05-03
yunzhonmghe 2020-04-07
cnflat0 2020-03-04
kevincheung 2020-02-20
neweastsun 2020-02-18
疯狂老司机 2020-02-13
xcguoyu 2019-12-04
纯粹的果子 2020-01-03
smalllove 2019-12-29
横云断岭 2019-12-29
zhaojp0 2019-12-29
javamagicsun 2019-12-11
Andrea0 2019-11-30