package com.jqmobile.core.orm; import java.sql.SQLException; import java.util.List; import java.util.UUID; import com.jqmobile.core.orm.exception.ORMException; /** * 定义常用操作方法 */ public interface ORM<T> extends ORMS{ /** * 添加数据 * @param t 实体类对象 * @return 返回操作行数 * @throws ORMException */ int insert(T t) throws ORMException; /** * 根据字符型id删除数据 * @param recid 主键id(16位uuid||guid)字符串形式 * @return 返回操作行数 * @throws ORMException */ int delete(String recid) throws ORMException; /** * 根据uuid对象删除数据 * @param recid uuid||guid * @return 返回操作行数 * @throws ORMException */ int delete(UUID recid) throws ORMException; /** * 自定义删除语句 * @param where delete语句where后面部分 * @param objs 参数数组 * @return int 返回响应条数 * @throws SQLException */ int delete(String where, Object...args) throws ORMException; /** * 修改数据 * @param t 实体类对象 * @return 返回操作行数 * @throws ORMException */ int update(T t) throws ORMException; /** * 自定义修改语句 * @param set update语句set后面部分 * @param objs 参数数组 * @return int 返回响应条数 * @throws SQLException */ int update(String set, Object...objs) throws ORMException; /** * 根据字符型id查找数据 * @param recid 主键id(16位uuid||guid)字符串形式 * @return 实体对象 */ T find(String recid); /** * 根据uuid对象查询数据 * @param recid uuid||guid * @return 实体对象 */ T find(UUID recid); /** * 查询所有记录 * @return 盛放所有数据对象的list * @throws ORMException */ List<T> getAll() throws ORMException; /** * sql查询 * @param where 查询条件(可只为where后条件,也可为整句sql) * @param args 占位符参数 * @return 盛放所有数据对象的list * @throws SQLException */ List<T> query(String where, Object... args) throws ORMException; /** * 分页查询 * @param where 查询条件 * @param startIndex 何处开始 * @param endIndex 何处结束 * @param args 占位符参数 * @return 盛放所有数据对象的list * @throws ORMException */ List<T> queryPage(String where, long startIndex, long endIndex, Object... args) throws ORMException; /** * 查询第一条数据(包含单条查询或多条查询) * @param where 查询条件 * @param args 占位符参数 * @return 实体对象 * @throws SQLException */ T queryFirst(String where, Object...args) throws ORMException; /** * 查询语句响应行数 * @param where 查询条件 * @param args 占位符参数 * @return int 响应行数 * @throws SQLException */ int queryRow(String where, Object...args) throws ORMException; }