- package org.minuzy.common.db.dao;
- import java.io.Serializable;
- import java.util.List;
- public interface DAO<Model extends Object, PK extends Serializable> {
- /**
- * 插入记录
- *
- * @param model
- * 对象
- * @return 成功插入记录行数
- */
- public int insert(Model model);
- /**
- * 批量插入
- *
- * @param models
- * 对象
- * @return 成功插入条数
- */
- public int insert(List<Model> models);
- /**
- * 根据ID, 删除记录
- *
- * @param pk
- * 对象模型ID
- * @return 是否操作成功. true:删除成功, false:删除失败
- */
- public boolean delete(PK pk);
- /**
- * 更加记录对象, 删除记录
- *
- * @param model
- * 对象
- * @return 是否操作成功. true:删除成功, false:删除失败
- */
- public boolean delete(Model model);
- /**
- * 更加记录对象, 删除记录
- *
- * @param model
- * 对象
- * @param restriction
- * 约束条件
- * @return 是否操作成功. true:删除成功, false:删除失败
- */
- public boolean delete(Model model, Restriction restriction);
- /**
- * 更新对象
- *
- * @param pk
- * ID
- * @param model
- * 目标对象
- * @return 更新条数
- */
- public int update(PK pk, Model model);
- /**
- * 更新对象
- *
- * @param arg0
- * 原对象
- * @param arg1
- * 目标对象
- * @return 更新条数
- */
- public int update(Model arg0, Model arg1);
- /**
- * 更新对象
- *
- * @param arg0
- * 原对象
- * @param arg1
- * 目标对象
- * @param restriction
- * 约束条件
- * @return 更新条数
- */
- public int update(Model arg0, Model arg1, Restriction restriction);
- /**
- * 查找记录
- *
- * @param pk
- * 对象ID
- * @return 查找结果, 未找到返回null
- */
- public Model findFirst(PK pk);
- /**
- * 查找记录
- *
- * @param model
- * 查找条件
- * @return 查找结果, 未找到返回null
- */
- public Model findFirst(Model model);
- /**
- * 查找记录
- *
- * @param model
- * 查找条件
- * @param restriction
- * 约束条件
- * @return 查找结果, 未找到返回null
- */
- public Model findFirst(Model model, Restriction restriction);
- /**
- * 查询记录
- *
- * @param model
- * 查找条件
- * @return 查找结果, 未找到返回null
- */
- public List<Model> find(Model model);
- /**
- * 查询记录
- *
- * @param model
- * 查找条件
- * @param restriction
- * 约束条件
- * @return 查找结果, 未找到返回null
- */
- public List<Model> find(Model model, Restriction restriction);
- /**
- * 获取记录条数
- *
- * @return 记录条数
- */
- public int total();
- /**
- * 获取记录条数
- *
- * @param model
- * 查找条件
- * @return 记录条数
- */
- public int total(Model model);
- /**
- * 获取记录条数
- *
- * @param restriction
- * 约束条件
- * @return 记录条数
- */
- public int total(Restriction restriction);
- }
- //该片段来自于http://www.codesnippet.cn/detail/140720149961.html
来源: http://www.codesnippet.cn/detail/140720149961.html