| 程序包 | 说明 |
|---|---|
| com.xiaoleilu.hutool.db | |
| com.xiaoleilu.hutool.db.dialect | |
| com.xiaoleilu.hutool.db.dialect.impl | |
| com.xiaoleilu.hutool.db.handler |
| 限定符和类型 | 方法和说明 |
|---|---|
<T extends Entity> |
Entity.removeEqual(T entity)
与给定实体对比并去除相同的部分
此方法用于在更新操作时避免所有字段被更新,跳过不需要更新的字段 version from 2.0.0 |
| 限定符和类型 | 方法和说明 |
|---|---|
static Entity |
Entity.create(String tableName) |
Entity |
Entity.parse(Object vo)
将值对象转换为Entity
类名会被当作表名,小写第一个字母 |
Entity |
Entity.set(String attr,
Object value)
设置列
|
Entity |
Entity.setIgnoreNull(String attr,
Object value)
设置列,当键或值为null时忽略
|
Entity |
Entity.setTableName(String tableName)
设置表名
|
Entity |
Wrapper.wrap(Entity entity)
包装字段名
有时字段与SQL的某些关键字冲突,导致SQL出错,因此需要将字段名用单引号或者反引号包装起来,避免冲突 |
| 限定符和类型 | 方法和说明 |
|---|---|
static Condition[] |
DbUtil.buildConditions(Entity entity)
通过实体对象构建条件对象
|
static String |
DbUtil.buildEqualsWhere(Entity entity,
List<Object> paramValues)
构件相等条件的where语句
如果没有条件语句,泽返回空串,表示没有条件 |
int |
SqlConnRunner.count(Connection conn,
Entity where)
结果的条目数
|
int |
SqlRunner.count(Entity where)
结果的条目数
|
int |
Session.count(Entity where)
结果的条目数
|
int |
SqlConnRunner.del(Connection conn,
Entity where)
删除数据
此方法不会关闭Connection |
int |
SqlRunner.del(Entity where)
删除数据
|
int |
Session.del(Entity where)
删除数据
|
<T> T |
SqlRunner.find(Collection<String> fields,
Entity where,
RsHandler<T> rsh)
查询
|
<T> T |
Session.find(Collection<String> fields,
Entity where,
RsHandler<T> rsh)
查询
|
<T> T |
SqlConnRunner.find(Connection conn,
Collection<String> fields,
Entity where,
RsHandler<T> rsh)
查询
此方法不会关闭Connection |
Long |
SqlConnRunner.insert(Connection conn,
Entity record)
插入数据
此方法不会关闭Connection |
Long |
SqlRunner.insert(Entity record)
插入数据
|
SqlBuilder |
SqlBuilder.insert(Entity entity)
插入
|
Long |
Session.insert(Entity record)
插入数据
|
<T> T |
SqlRunner.page(Collection<String> fields,
Entity where,
int page,
int numPerPage,
RsHandler<T> rsh)
分页查询
|
<T> T |
Session.page(Collection<String> fields,
Entity where,
int page,
int numPerPage,
RsHandler<T> rsh)
分页查询
|
<T> T |
SqlConnRunner.page(Connection conn,
Collection<String> fields,
Entity where,
int page,
int numPerPage,
RsHandler<T> rsh)
分页查询
此方法不会关闭Connection |
int |
SqlConnRunner.update(Connection conn,
Entity record,
Entity where)
更新数据
此方法不会关闭Connection |
SqlBuilder |
SqlBuilder.update(Entity entity)
更新
|
int |
SqlRunner.update(Entity record,
Entity where)
更新数据
|
int |
Session.update(Entity record,
Entity where)
更新数据
|
static void |
DbUtil.validateEntity(Entity entity)
验证实体类对象的有效性
|
Entity |
Wrapper.wrap(Entity entity)
包装字段名
有时字段与SQL的某些关键字冲突,导致SQL出错,因此需要将字段名用单引号或者反引号包装起来,避免冲突 |
| 限定符和类型 | 方法和说明 |
|---|---|
PreparedStatement |
Dialect.psForCount(Connection conn,
Entity where)
构建用于查询行数的PreparedStatement
|
PreparedStatement |
Dialect.psForDelete(Connection conn,
Entity entity)
构建用于删除的PreparedStatement
|
PreparedStatement |
Dialect.psForFind(Connection conn,
Collection<String> fields,
Entity where)
构建用于获取多条记录的PreparedStatement
|
PreparedStatement |
Dialect.psForInsert(Connection conn,
Entity entity)
构建用于插入的PreparedStatement
|
PreparedStatement |
Dialect.psForPage(Connection conn,
Collection<String> fields,
Entity where,
int page,
int numPerPage)
构建用于分页查询的PreparedStatement
|
PreparedStatement |
Dialect.psForPage(Connection conn,
Collection<String> fields,
Entity where,
int page,
int numPerPage,
Collection<String> orderFields,
SqlBuilder.Order order)
构建用于分页查询的PreparedStatement
|
PreparedStatement |
Dialect.psForUpdate(Connection conn,
Entity entity,
Entity where)
构建用于更新的PreparedStatement
|
| 限定符和类型 | 方法和说明 |
|---|---|
Entity |
SingleEntityHandler.handle(ResultSet rs) |
static Entity |
HandleHelper.handleRow(int columnCount,
ResultSetMetaData meta,
ResultSet rs)
处理单条数据
|
| 限定符和类型 | 方法和说明 |
|---|---|
List<Entity> |
EntityHandler.handle(ResultSet rs) |
Copyright © 2015. All rights reserved.