加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

一个支持泛型的DAO接口类

发布时间:2020-05-25 14:03:25 所属栏目:Java 来源:互联网
导读:一个支持泛型的DAO接口类

下面是脚本之家 jb51.cc 通过网络收集整理的代码片段。

脚本之家小编现在分享给大家,也给大家做个参考。

 
/**
 * Defines a generic DAO interface.
 * 
 * @author javier
 * 
 * @param <T>
 *            The type this DAO handles.
 * @param <ID>
 *            The type of the id of the handled entity.
 */
public interface DAOInterface<T,ID extends Serializable>
{

    /**
     * Makes the given entity persistent.
     *
     * @param entity The entity to persist.
     * @throws When the quota of instances for that entity was exceeded.
     */
    void makePersistent(T entity) throws QuotaExceededException;

    /**
     * Makes the given entity transient.
     *
     * @param entity The entity to make transient.
     */
    void makeTransient(T entity);

    /**
     * @return the number of matching entities.
     */
    int count(Filter filter);

    /**
     * Returns a single entity which has the given ID or throws an
     * <code>EntityNotFoundException</code> if no matching entity is found.
     * 
     * @param id
     *            The ID of the entity to return.
     * @return The entity.
     */
    T findById(ID id) throws EntityNotFoundException;

    /**
     * Returns all matching entities of type <code>T</code>.
     * 
     * @param filter
     *            The <code>Filter</code> to use.
     *
     * @return An ordered <code>List</code> with the entities.
     */
    List<T> find(Filter filter);

    /**
     * Returns all entities of type <code>T</code>.
     * 
     * @return An ordered <code>List</code> with the entities.
     */
    List<T> findAll();

    /**
     * Returns a page of entities.
     * 
     * @param filter
     *            The <code>Filter</code> to use.
     * @param startRow
     *            The offset.
     * @param pageSize
     *            The number of entities to return.
     *
     * @return A <code>Pair</code> of values. The first value is the
     *         <code>List</code> of entities and the second one if the total
     *         number of existing entities.
     */
    Pair<List<T>,Integer> findPaged(Filter filter,int startRow,int pageSize);

    /**
     * Flushing is the process of synchronising the underlying persistent
     * store with persistable state held in memory. 
     */
    void flush();
}
 

以上是脚本之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得脚本之家网站内容还不错,欢迎将脚本之家网站推荐给程序员好友。

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读