| 限定符和类型 | 字段和说明 |
|---|---|
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)
查询
|
<T> T |
find(Entity where,
RsHandler<T> rsh)
查询,返回所有字段
|
List<Entity> |
findAll(Entity where)
查询数据列表,返回所有字段
|
List<Entity> |
findAll(String tableName)
查询数据列表,返回所有字段
|
List<Entity> |
findBy(String tableName,
String field,
Object value)
根据某个字段名条件查询数据列表,返回所有字段
|
List<Entity> |
findLike(String tableName,
String field,
String value,
Condition.LikeType likeType)
根据某个字段名条件查询数据列表,返回所有字段
|
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)
分页查询
|
<T> T |
page(Collection<String> fields,
Entity where,
int page,
int numPerPage,
RsHandler<T> rsh)
分页查询
|
PageResult<Entity> |
page(Collection<String> fields,
Entity where,
Page page)
分页查询
|
<T> T |
page(Collection<String> fields,
Entity where,
Page page,
RsHandler<T> rsh)
分页查询
|
PageResult<Entity> |
page(Entity where,
Page page)
分页查询
|
<T> T |
query(String sql,
RsHandler<T> rsh,
Object... params)
查询
|
void |
setRunner(SqlConnRunner runner) |
int |
update(Entity record,
Entity where)
更新数据
|
protected SqlConnRunner runner
public abstract Connection getConnection() throws SQLException
ConnectionSQLExceptionpublic abstract void closeConnection(Connection conn)
conn - 连接 Connectionpublic <T> T query(String sql, RsHandler<T> rsh, Object... params) throws SQLException
sql - 查询语句rsh - 结果集处理对象params - 参数SQLExceptionpublic int execute(String sql, Object... params) throws SQLException
sql - SQLparams - 参数SQLExceptionpublic Long executeForGeneratedKey(String sql, Object... params) throws SQLException
sql - SQLparams - 参数SQLExceptionpublic int[] executeBatch(String sql, Object[]... paramsBatch) throws SQLException
sql - SQLparamsBatch - 批量的参数SQLExceptionpublic int insert(Entity record) throws SQLException
record - 记录SQLExceptionpublic int[] insert(Collection<Entity> records) throws SQLException
records - 记录列表SQLExceptionpublic List<Object> insertForGeneratedKeys(Entity record) throws SQLException
record - 记录SQLExceptionpublic Long insertForGeneratedKey(Entity record) throws SQLException
record - 记录SQLExceptionpublic int del(String tableName, String field, Object value) throws SQLException
tableName - 表名field - 字段名,最好是主键value - 值,值可以是列表或数组,被当作IN查询处理SQLExceptionpublic int del(Entity where) throws SQLException
where - 条件SQLExceptionpublic int update(Entity record, Entity where) throws SQLException
record - 记录SQLExceptionpublic <T> T find(Collection<String> fields, Entity where, RsHandler<T> rsh) throws SQLException
fields - 返回的字段列表,null则返回所有字段where - 条件实体类(包含表名)rsh - 结果集处理对象SQLExceptionpublic <T> T find(Entity where, RsHandler<T> rsh) throws SQLException
where - 条件实体类(包含表名)rsh - 结果集处理对象SQLExceptionpublic List<Entity> findAll(Entity where) throws SQLException
where - 条件实体类(包含表名)SQLExceptionpublic List<Entity> findAll(String tableName) throws SQLException
tableName - 表名SQLExceptionpublic List<Entity> findBy(String tableName, String field, Object value) throws SQLException
tableName - 表名field - 字段名value - 字段值SQLExceptionpublic List<Entity> findLike(String tableName, String field, String value, Condition.LikeType likeType) throws SQLException
tableName - 表名field - 字段名value - 字段值likeType - Condition.LikeTypeSQLExceptionpublic int count(Entity where) throws SQLException
where - 查询条件SQLExceptionpublic <T> T page(Collection<String> fields, Entity where, int page, int numPerPage, RsHandler<T> rsh) throws SQLException
fields - 返回的字段列表,null则返回所有字段where - 条件实体类(包含表名)page - 页码numPerPage - 每页条目数rsh - 结果集处理对象SQLExceptionpublic <T> T page(Collection<String> fields, Entity where, Page page, RsHandler<T> rsh) throws SQLException
fields - 返回的字段列表,null则返回所有字段where - 条件实体类(包含表名)page - 分页对象rsh - 结果集处理对象SQLExceptionpublic PageResult<Entity> page(Collection<String> fields, Entity where, int page, int numPerPage) throws SQLException
fields - 返回的字段列表,null则返回所有字段where - 条件实体类(包含表名)page - 页码numPerPage - 每页条目数SQLExceptionpublic PageResult<Entity> page(Collection<String> fields, Entity where, Page page) throws SQLException
fields - 返回的字段列表,null则返回所有字段where - 条件实体类(包含表名)page - 页码SQLExceptionpublic PageResult<Entity> page(Entity where, Page page) throws SQLException
where - 条件实体类(包含表名)page - 页码SQLExceptionpublic SqlConnRunner getRunner()
public void setRunner(SqlConnRunner runner)
Copyright © 2017. All rights reserved.