dao层中的配置IBaseDao,所有的dao可以继承此类

[java]   view plain copy print ?
  1. package com.hfxt.dao;  
  2.   
  3. import java.io.Serializable;  
  4. import java.util.List;  
  5. import java.util.Map;  
  6.   
  7. import com.hfxt.common.Pager;  
  8. import com.hfxt.exception.HibernateDaoSupportException;  
  9. /** 
  10.  * 定义所有DAO接口的父接口,用以提供一些通用的方法,并通过泛型实现一些DAO的通用功能 该接口继承自appfuse框架的GenericDao接口 
  11.  * 自定义DAO接口是,要继承该DAO,使用示例: UserDao extends BaseDao<User, Integer> { ... } 
  12.  *  
  13.  */  
  14. public interface IBaseDao<T,PK extends Serializable> {  
  15.   
  16.   
  17.      /** 
  18.      * The <code>queryList(PK startRecord, PK pageSize)</code> method is query 
  19.      * objects according startRecord and pagesize're number, object type is 
  20.      * according your implements this method's define type, and implements this 
  21.      * interface abstract class must be override all method and inject entity 
  22.      * type. 
  23.      *  
  24.      * @param startRecord 
  25.      *            Where from the beginning to show this record 
  26.      * @param pageSize 
  27.      *            The number of records per page 
  28.      * @param clazz 
  29.      *            according class 
  30.      * @return List<T> T is your inject object's type, List is query all object 
  31.      *         connection 
  32.      *  
  33.      * @throws HibernateDaoSupportException 
  34.      *             Throws HibernateDaoSupportException when accessing and 
  35.      *             manipulating database happen exception. 
  36.      */  
  37.     public List<T> queryList(int startRecord, int pageSize, Class<T> clazz)  
  38.             throws HibernateDaoSupportException;  
  39.   
  40.     /** 
  41.      * The <code>getRecordCount()</code> method is used for getting the total 
  42.      * count of records. 
  43.      *  
  44.      * @return PK return total of record counts 
  45.      * @throws HibernateDaoSupportException 
  46.      *             Throws HibernateDaoSupportException when accessing and 
  47.      *             manipulating database happen exception. 
  48.      */  
  49.     public long getRecordCount(Class<T> clazz)  
  50.             throws HibernateDaoSupportException;  
  51.   
  52.     /** 
  53.      * The <code>find(T entity)</code> method is find object according object 
  54.      * type. 
  55.      *  
  56.      * @param entity 
  57.      *            if you want to find class condition. 
  58.      * @return List<T> according entity to find object's connection. 
  59.      * @throws HibernateDaoSupportException 
  60.      *             Throws HibernateDaoSupportException when accessing and 
  61.      *             manipulating database happen exception. 
  62.      *  
  63.      */  
  64.     public List<T> find(T entity) throws HibernateDaoSupportException;  
  65.   
  66.     /** 
  67.      * The <code>findById(PK id)</code> method is find object according 
  68.      * primary key. 
  69.      *  
  70.      * @param id 
  71.      *            if you want to find object's primary key 
  72.      * @return T insject object 
  73.      * @throws HibernateDaoSupportException 
  74.      *             Throws HibernateDaoSupportException when accessing and 
  75.      *             manipulating database happen exception. 
  76.      */  
  77.     public T findById(PK id, Class<T> clazz)  
  78.             throws HibernateDaoSupportException;  
  79.   
  80.     /** 
  81.      * The <code>add(T entity)</code> method is add object to database. 
  82.      *  
  83.      * @param entity 
  84.      *            if you want to add entity. 
  85.      *  
  86.      * @throws HibernateDaoSupportException 
  87.      *             Throws HibernateDaoSupportException when accessing and 
  88.      *             manipulating database happen exception. 
  89.      */  
  90.     public PK add(T entity) throws HibernateDaoSupportException;  
  91.   
  92.     /** 
  93.      * The <code>delete(T entity)</code> method is delete object to database. 
  94.      *  
  95.      * @param entity 
  96.      *            if you want to delete entity. 
  97.      *  
  98.      * @throws HibernateDaoSupportException 
  99.      *             Throws HibernateDaoSupportException when accessing and 
  100.      *             manipulating database happen exception. 
  101.      */  
  102.     public void delete(T entity) throws HibernateDaoSupportException;  
  103.   
  104.     /** 
  105.      * The <code>modifty(T entity)</code> method is update object to database. 
  106.      *  
  107.      * @param entity 
  108.      *            if you want to update entity. 
  109.      * @throws HibernateDaoSupportException 
  110.      *             Throws HibernateDaoSupportException when accessing and 
  111.      *             manipulating database happen exception. 
  112.      */  
  113.     public void modify(T entity) throws HibernateDaoSupportException;  
  114.   
  115.     /** 
  116.      * find page object's connection with class 
  117.      *  
  118.      * @param clazz 
  119.      *            according class 
  120.      * @param currentPage 
  121.      *            current page 
  122.      * @param pageSize 
  123.      *            the number of records per page 
  124.      * @return Object's connection 
  125.      * @throws HibernateDaoSupportException 
  126.      *             when accessing and manipulating database happen exception 
  127.      */  
  128.     public Pager<T> findPager(int currentPage, int pageSize, Class<T> clazz)  
  129.             throws HibernateDaoSupportException;  
  130.   
  131.     /** 
  132.      * find page object's connection with hql and param map 
  133.      *  
  134.      * @param hql 
  135.      *            according hql if class param is null 
  136.      * @param currentPage 
  137.      *            current page 
  138.      * @param pageSize 
  139.      *            the number of records per page 
  140.      * @param properties 
  141.      *            according param map 
  142.      * @return Object's connection 
  143.      * @throws HibernateDaoSupportException 
  144.      *             when accessing and manipulating database happen exception 
  145.      */  
  146.     public Pager<T> findPager(String hql, int currentPage, int pageSize,  
  147.             Map<String, Object> properties) throws HibernateDaoSupportException;  
  148.   
  149.     /** 
  150.      * find object's connection with hql 
  151.      *  
  152.      * @param hql 
  153.      *            according hql 
  154.      * @return Object's connection 
  155.      * @throws HibernateDaoSupportException 
  156.      *             when accessing and manipulating database happen exception 
  157.      */  
  158.     public List<T> getObjects(String hql) throws HibernateDaoSupportException;  
  159.   
  160.     /** 
  161.      * find object's connection with hql and param map 
  162.      *  
  163.      * @param hql 
  164.      *            according hql 
  165.      * @param properties 
  166.      *            according param map 
  167.      * @return Object's connection 
  168.      * @throws HibernateDaoSupportException 
  169.      *             when accessing and manipulating database happen exception 
  170.      */  
  171.     public List<T> getObjects(String hql, Map<String, Object> properties)  
  172.             throws HibernateDaoSupportException;  
  173.   
  174.     /** 
  175.      * find object with hql and param map 
  176.      *  
  177.      * @param hql 
  178.      *            according hql 
  179.      * @param properties 
  180.      *            according param map 
  181.      * @return Object which find 
  182.      * @throws HibernateDaoSupportException 
  183.      *             when accessing and manipulating database happen exception 
  184.      */  
  185.     public Object getUniqueBeanResult(String hql, Map<String, Object> properties)  
  186.             throws HibernateDaoSupportException;  
  187.   
  188.     /** 
  189.      * find object with hql 
  190.      *  
  191.      * @param hql 
  192.      *            according hql 
  193.      * @return Object which find 
  194.      * @throws HibernateDaoSupportException 
  195.      *             when accessing and manipulating database happen exception 
  196.      */  
  197.     public Object getUniqueBeanResult(String hql)  
  198.             throws HibernateDaoSupportException;  
  199.   
  200.     /** 
  201.      * update entity with hql and param map 
  202.      *  
  203.      * @param hql 
  204.      *            according hql 
  205.      * @param properties 
  206.      *            according param map 
  207.      * @return the count of success record 
  208.      * @throws HibernateDaoSupportException 
  209.      *             when accessing and manipulating database happen exception 
  210.      */  
  211.     public int executeUpdate(String hql, Map<String, Object> properties)  
  212.             throws HibernateDaoSupportException;  
  213.   
  214.     /** 
  215.      * update entity with hql and param arrary 
  216.      *  
  217.      * @param hql 
  218.      *            according hql 
  219.      * @param values 
  220.      *            according param arrary 
  221.      * @return the count of success record 
  222.      * @throws HibernateDaoSupportException 
  223.      *             when accessing and manipulating database happen exception 
  224.      */  
  225.     public int executeUpdate(String hql, Object[] values)  
  226.             throws HibernateDaoSupportException;  
  227.   
  228.     /** 
  229.      * find object's connection with hql class and param map 
  230.      *  
  231.      * @param hql 
  232.      *            according hql if class param is null 
  233.      * @param startRecord 
  234.      *            Where from the beginning to show this record 
  235.      * @param pageSize 
  236.      *            the number of records per page 
  237.      * @param clazz 
  238.      *            according class 
  239.      * @param properties 
  240.      *            according param map 
  241.      * @return Object's connection 
  242.      * @throws HibernateDaoSupportException 
  243.      *             when accessing and manipulating database happen exception 
  244.      */  
  245.     public List<T> queryList(String hql, int startRecord, int pageSize,  
  246.             Class<T> clazz, Map<String, Object> properties)  
  247.             throws HibernateDaoSupportException;  
  248.   
  249.     /** 
  250.      * find object's connection with class 
  251.      *  
  252.      * @param clazz 
  253.      *            according class 
  254.      * @return Object's connection 
  255.      * @throws HibernateDaoSupportException 
  256.      *             when accessing and manipulating database happen exception 
  257.      */  
  258.     public List<T> find(Class<T> clazz) throws HibernateDaoSupportException;  
  259.   
  260.     /** 
  261.      * execute with sql and param arrary 
  262.      *  
  263.      * @param sql 
  264.      *            according sql 
  265.      * @param values 
  266.      *            according param arrary 
  267.      * @return the count of success record 
  268.      * @throws HibernateDaoSupportException 
  269.      *             when accessing and manipulating database happen exception 
  270.      */  
  271.     public int executeSql(final String sql, final Map<String, Object> values)  
  272.             throws HibernateDaoSupportException;  
  273.       
  274.     /** 
  275.      * set method is need CacheQueries 
  276.      * @param isCacheQueries is cache queries 
  277.      */  
  278.     public void setCacheQueries(boolean isCacheQueries);  
  279.       
  280.       
  281.     public void saveOrUpdateEntity(T entity);  
  282.       
  283.     /** 
  284.      * find object's connection with sql class and param map 
  285.      *  
  286.      * @param sql 
  287.      *            according sql if class param is null 
  288.      * @param startRecord 
  289.      *            Where from the beginning to show this record 
  290.      * @param pageSize 
  291.      *            the number of records per page 
  292.      * @param properties 
  293.      *            according param map 
  294.      * @return Object's connection 
  295.      * @throws HibernateDaoSupportException 
  296.      *             when accessing and manipulating database happen exception 
  297.      */  
  298.     @SuppressWarnings("unchecked")  
  299.     public List queryListSql(final String sql, final int startRecord,  
  300.             final int pageSize, final Map<String, Object> properties)  
  301.             throws HibernateDaoSupportException;  
  302.       
  303.     public Pager findPagerBySql(String sql, int currentPage,  
  304.             int pageSize, Map<String, Object> properties)  
  305.             throws HibernateDaoSupportException;  
  306.       
  307.           
  308.   
  309.     public List<T> queryListByHql(String hql,Class<T> clazz,Map<String, Object> properties) throws HibernateDaoSupportException;  
  310.       
  311.     /** 
  312.      * 查询 
  313.      * @param hql 
  314.      * @param properties 
  315.      * @return 
  316.      * @throws HibernateDaoSupportException 
  317.      */  
  318.     public List queryListByHql(String hql,final Map<String, Object> properties) throws HibernateDaoSupportException;  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值