public abstract class AbstractSqlRunner extends Object
| 限定符和类型 | 字段和说明 | 
|---|---|
| protected SqlConnRunner | runner | 
| 构造器和说明 | 
|---|
| AbstractSqlRunner() | 
| 限定符和类型 | 方法和说明 | 
|---|---|
| abstract void | closeConnection(Connection conn)关闭连接 自定义关闭连接有利于自定义回收连接机制,或者不关闭 | 
| int | count(Entity where)结果的条目数 | 
| int | del(Entity where)删除数据 | 
| int | del(String tableName,
   String field,
   Object value)删除数据 | 
| int | execute(String sql,
       Object... params)执行非查询语句 语句包括 插入、更新、删除 | 
| int[] | executeBatch(String sql,
            Object[]... paramsBatch)批量执行非查询语句 | 
| Long | executeForGeneratedKey(String sql,
                      Object... params)执行非查询语句 语句包括 插入、更新、删除 | 
| <T> T | find(Collection<String> fields,
    Entity where,
    RsHandler<T> rsh)查询 查询条件为多个key value对表示,默认key = value,如果使用其它条件可以使用:where.put("key", " > 1"),value也可以传Condition对象,key被忽略 | 
| List<Entity> | find(Entity where)查询数据列表,返回字段由where参数指定 查询条件为多个key value对表示,默认key = value,如果使用其它条件可以使用:where.put("key", " > 1"),value也可以传Condition对象,key被忽略 | 
| <T> List<T> | find(Entity where,
    Class<T> beanClass)查询数据列表,返回字段由where参数指定 查询条件为多个key value对表示,默认key = value,如果使用其它条件可以使用:where.put("key", " > 1"),value也可以传Condition对象,key被忽略 | 
| <T> T | find(Entity where,
    RsHandler<T> rsh,
    String... fields)查询,返回所有字段 查询条件为多个key value对表示,默认key = value,如果使用其它条件可以使用:where.put("key", " > 1"),value也可以传Condition对象,key被忽略 | 
| <T> T | find(Query query,
    RsHandler<T> rsh)查询 Query为查询所需数据的一个实体类,此对象中可以定义返回字段、查询条件,查询的表、分页等信息 | 
| List<Entity> | findAll(Entity where)查询数据列表,返回所有字段 查询条件为多个key value对表示,默认key = value,如果使用其它条件可以使用:where.put("key", " > 1"),value也可以传Condition对象,key被忽略 | 
| <T> List<T> | findAll(Entity where,
       Class<T> beanClass)查询数据列表,返回所有字段 查询条件为多个key value对表示,默认key = value,如果使用其它条件可以使用:where.put("key", " > 1"),value也可以传Condition对象,key被忽略 | 
| List<Entity> | findAll(String tableName)查询数据列表,返回所有字段 | 
| List<Entity> | findBy(String tableName,
      Condition... wheres)根据某个字段名条件查询数据列表,返回所有字段 | 
| List<Entity> | findBy(String tableName,
      String field,
      Object value)根据某个字段名条件查询数据列表,返回所有字段 | 
| List<Entity> | findLike(String tableName,
        String field,
        String value,
        Condition.LikeType likeType)根据某个字段名条件查询数据列表,返回所有字段 | 
| Entity | get(Entity where)根据条件实体查询单个记录,当有多条返回时,只显示查询到的第一条 | 
| <T> Entity | get(String tableName,
   String field,
   T value)根据某个字段(最好是唯一字段)查询单个记录 当有多条返回时,只显示查询到的第一条 | 
| abstract Connection | getConnection()获得链接。 | 
| SqlConnRunner | getRunner() | 
| int[] | insert(Collection<Entity> records)批量插入数据 需要注意的是,批量插入每一条数据结构必须一致。 | 
| int | insert(Entity record)插入数据 | 
| Long | insertForGeneratedKey(Entity record)插入数据 | 
| List<Object> | insertForGeneratedKeys(Entity record)插入数据 | 
| PageResult<Entity> | page(Collection<String> fields,
    Entity where,
    int page,
    int numPerPage)分页查询 查询条件为多个key value对表示,默认key = value,如果使用其它条件可以使用:where.put("key", " > 1"),value也可以传Condition对象,key被忽略 | 
| <T> T | page(Collection<String> fields,
    Entity where,
    int page,
    int numPerPage,
    RsHandler<T> rsh)分页查询 查询条件为多个key value对表示,默认key = value,如果使用其它条件可以使用:where.put("key", " > 1"),value也可以传Condition对象,key被忽略 | 
| PageResult<Entity> | page(Collection<String> fields,
    Entity where,
    Page page)分页查询 查询条件为多个key value对表示,默认key = value,如果使用其它条件可以使用:where.put("key", " > 1"),value也可以传Condition对象,key被忽略 | 
| <T> T | page(Collection<String> fields,
    Entity where,
    Page page,
    RsHandler<T> rsh)分页查询 查询条件为多个key value对表示,默认key = value,如果使用其它条件可以使用:where.put("key", " > 1"),value也可以传Condition对象,key被忽略 | 
| PageResult<Entity> | page(Entity where,
    int page,
    int numPerPage)分页查询 查询条件为多个key value对表示,默认key = value,如果使用其它条件可以使用:where.put("key", " > 1"),value也可以传Condition对象,key被忽略 | 
| <T> T | page(Entity where,
    int page,
    int numPerPage,
    RsHandler<T> rsh)分页查询 查询条件为多个key value对表示,默认key = value,如果使用其它条件可以使用:where.put("key", " > 1"),value也可以传Condition对象,key被忽略 | 
| PageResult<Entity> | page(Entity where,
    Page page)分页查询 查询条件为多个key value对表示,默认key = value,如果使用其它条件可以使用:where.put("key", " > 1"),value也可以传Condition对象,key被忽略 | 
| <T> T | page(Entity where,
    Page page,
    RsHandler<T> rsh)分页查询 查询条件为多个key value对表示,默认key = value,如果使用其它条件可以使用:where.put("key", " > 1"),value也可以传Condition对象,key被忽略 | 
| List<Entity> | pageForEntityList(Entity where,
                 int page,
                 int numPerPage)分页查询,结果为Entity列表,不计算总数 查询条件为多个key value对表示,默认key = value,如果使用其它条件可以使用:where.put("key", " > 1"),value也可以传Condition对象,key被忽略 | 
| List<Entity> | pageForEntityList(Entity where,
                 Page page)分页查询,结果为Entity列表,不计算总数 查询条件为多个key value对表示,默认key = value,如果使用其它条件可以使用:where.put("key", " > 1"),value也可以传Condition对象,key被忽略 | 
| <T> List<T> | query(String sql,
     Class<T> beanClass,
     Object... params)查询 | 
| List<Entity> | query(String sql,
     Object... params)查询 | 
| <T> T | query(String sql,
     RsHandler<T> rsh,
     Object... params)查询 | 
| Number | queryNumber(String sql,
           Object... params)查询单条单个字段记录,并将其转换为Number | 
| Entity | queryOne(String sql,
        Object... params)查询单条记录 | 
| String | queryString(String sql,
           Object... params)查询单条单个字段记录,并将其转换为String | 
| void | setRunner(SqlConnRunner runner) | 
| AbstractSqlRunner | setWrapper(Character wrapperChar)设置包装器,包装器用于对表名、字段名进行符号包装(例如双引号),防止关键字与这些表名或字段冲突 | 
| AbstractSqlRunner | setWrapper(Wrapper wrapper)设置包装器,包装器用于对表名、字段名进行符号包装(例如双引号),防止关键字与这些表名或字段冲突 | 
| int | update(Entity record,
      Entity where)更新数据 更新条件为多个key value对表示,默认key = value,如果使用其它条件可以使用:where.put("key", " > 1"),value也可以传Condition对象,key被忽略 | 
protected SqlConnRunner runner
public abstract Connection getConnection() throws SQLException
ConnectionSQLException - 连接获取异常public abstract void closeConnection(Connection conn)
conn - 连接 Connectionpublic List<Entity> query(String sql, Object... params) throws SQLException
sql - 查询语句params - 参数SQLException - SQL执行异常public <T> List<T> query(String sql, Class<T> beanClass, Object... params) throws SQLException
T - 结果集需要处理的对象类型sql - 查询语句beanClass - 元素Bean类型params - 参数SQLException - SQL执行异常public Entity queryOne(String sql, Object... params) throws SQLException
sql - 查询语句params - 参数SQLException - SQL执行异常public Number queryNumber(String sql, Object... params) throws SQLException
sql - 查询语句params - 参数SQLException - SQL执行异常public String queryString(String sql, Object... params) throws SQLException
sql - 查询语句params - 参数SQLException - SQL执行异常public <T> T query(String sql, RsHandler<T> rsh, Object... params) throws SQLException
T - 结果集需要处理的对象类型sql - 查询语句rsh - 结果集处理对象params - 参数SQLException - SQL执行异常public int execute(String sql, Object... params) throws SQLException
sql - SQLparams - 参数SQLException - SQL执行异常public Long executeForGeneratedKey(String sql, Object... params) throws SQLException
sql - SQLparams - 参数SQLException - SQL执行异常public int[] executeBatch(String sql, Object[]... paramsBatch) throws SQLException
sql - SQLparamsBatch - 批量的参数SQLException - SQL执行异常public int insert(Entity record) throws SQLException
record - 记录SQLException - SQL执行异常public int[] insert(Collection<Entity> records) throws SQLException
records - 记录列表SQLException - SQL执行异常public List<Object> insertForGeneratedKeys(Entity record) throws SQLException
record - 记录SQLException - SQL执行异常public Long insertForGeneratedKey(Entity record) throws SQLException
record - 记录SQLException - SQL执行异常public int del(String tableName, String field, Object value) throws SQLException
tableName - 表名field - 字段名,最好是主键value - 值,值可以是列表或数组,被当作IN查询处理SQLException - SQL执行异常public int del(Entity where) throws SQLException
where - 条件SQLException - SQL执行异常public int update(Entity record, Entity where) throws SQLException
record - 记录where - 条件SQLException - SQL执行异常public <T> Entity get(String tableName, String field, T value) throws SQLException
T - 字段值类型tableName - 表名field - 字段名value - 字段值SQLException - SQL执行异常public Entity get(Entity where) throws SQLException
where - 条件SQLException - SQL执行异常public <T> T find(Collection<String> fields, Entity where, RsHandler<T> rsh) throws SQLException
T - 需要处理成的结果对象类型fields - 返回的字段列表,null则返回所有字段where - 条件实体类(包含表名)rsh - 结果集处理对象SQLException - SQL执行异常public <T> T find(Query query, RsHandler<T> rsh) throws SQLException
T - 需要处理成的结果对象类型query - Query对象,此对象中可以定义返回字段、查询条件,查询的表、分页等信息rsh - 结果集处理对象SQLException - SQL执行异常public <T> T find(Entity where, RsHandler<T> rsh, String... fields) throws SQLException
T - 需要处理成的结果对象类型where - 条件实体类(包含表名)rsh - 结果集处理对象fields - 字段列表,可变长参数如果无值表示查询全部字段SQLException - SQL执行异常public List<Entity> find(Entity where) throws SQLException
where - 条件实体类(包含表名)SQLException - SQL执行异常public <T> List<T> find(Entity where, Class<T> beanClass) throws SQLException
T - Bean类型where - 条件实体类(包含表名)SQLException - SQL执行异常public List<Entity> findAll(Entity where) throws SQLException
where - 条件实体类(包含表名)SQLException - SQL执行异常public <T> List<T> findAll(Entity where, Class<T> beanClass) throws SQLException
T - Bean类型where - 条件实体类(包含表名)SQLException - SQL执行异常public List<Entity> findAll(String tableName) throws SQLException
tableName - 表名SQLException - SQL执行异常public List<Entity> findBy(String tableName, String field, Object value) throws SQLException
tableName - 表名field - 字段名value - 字段值SQLException - SQL执行异常public List<Entity> findBy(String tableName, Condition... wheres) throws SQLException
tableName - 表名wheres - 字段名SQLException - SQL执行异常public List<Entity> findLike(String tableName, String field, String value, Condition.LikeType likeType) throws SQLException
tableName - 表名field - 字段名value - 字段值likeType - Condition.LikeTypeSQLException - SQL执行异常public int count(Entity where) throws SQLException
where - 查询条件SQLException - SQL执行异常public <T> T page(Collection<String> fields, Entity where, int page, int numPerPage, RsHandler<T> rsh) throws SQLException
T - 结果对象类型fields - 返回的字段列表,null则返回所有字段where - 条件实体类(包含表名)page - 页码numPerPage - 每页条目数rsh - 结果集处理对象SQLException - SQL执行异常public <T> T page(Entity where, int page, int numPerPage, RsHandler<T> rsh) throws SQLException
T - 结果对象类型where - 条件实体类(包含表名)page - 页码numPerPage - 每页条目数rsh - 结果集处理对象SQLException - SQL执行异常public List<Entity> pageForEntityList(Entity where, int page, int numPerPage) throws SQLException
where - 条件实体类(包含表名)page - 页码numPerPage - 每页条目数SQLException - SQL执行异常public List<Entity> pageForEntityList(Entity where, Page page) throws SQLException
where - 条件实体类(包含表名)page - 分页对象SQLException - SQL执行异常public <T> T page(Entity where, Page page, RsHandler<T> rsh) throws SQLException
T - 结果对象类型where - 条件实体类(包含表名)page - 分页对象rsh - 结果集处理对象SQLException - SQL执行异常public <T> T page(Collection<String> fields, Entity where, Page page, RsHandler<T> rsh) throws SQLException
T - 结果对象类型fields - 返回的字段列表,null则返回所有字段where - 条件实体类(包含表名)page - 分页对象rsh - 结果集处理对象SQLException - SQL执行异常public PageResult<Entity> page(Collection<String> fields, Entity where, int page, int numPerPage) throws SQLException
fields - 返回的字段列表,null则返回所有字段where - 条件实体类(包含表名)page - 分页对象numPerPage - 每页条目数SQLException - SQL执行异常public PageResult<Entity> page(Collection<String> fields, Entity where, Page page) throws SQLException
fields - 返回的字段列表,null则返回所有字段where - 条件实体类(包含表名)page - 分页对象SQLException - SQL执行异常public PageResult<Entity> page(Entity where, int page, int numPerPage) throws SQLException
where - 条件实体类(包含表名)page - 页码numPerPage - 每页条目数SQLException - SQL执行异常public PageResult<Entity> page(Entity where, Page page) throws SQLException
where - 条件实体类(包含表名)page - 分页对象SQLException - SQL执行异常public SqlConnRunner getRunner()
SqlConnRunnerpublic void setRunner(SqlConnRunner runner)
runner - SqlConnRunnerpublic AbstractSqlRunner setWrapper(Character wrapperChar)
wrapperChar - 包装字符,字符会在SQL生成时位于表名和字段名两边,null时表示取消包装public AbstractSqlRunner setWrapper(Wrapper wrapper)
wrapper - 包装器,null表示取消包装Copyright © 2021. All rights reserved.