| 限定符和类型 | 字段和说明 |
|---|---|
(专用程序包) static RowMapperInvoker |
defaultRowMapperInvoker |
private static Map<String,RowMapperInvoker> |
INVOKER_MAP |
| 构造器和说明 |
|---|
Db() |
| 限定符和类型 | 方法和说明 |
|---|---|
static int |
deleteBatchByIds(String tableName,
String primaryKey,
Collection<?> ids)
根据 id 集合来批量删除数据
|
static int |
deleteByCondition(String tableName,
QueryCondition condition)
根据 condition 条件删除数据
|
static int |
deleteById(String tableName,
Row row)
根据主键来删除数据,其中 row 是通过
Row.ofKey(RowKey, Object) 来进行构建的 |
static int |
deleteById(String tableName,
String primaryKey,
Object id)
根据主键来删除 1 条数据
|
static int |
deleteByMap(String tableName,
Map<String,Object> whereColumns)
根据 map 构建的 where 条件来删除数据
|
static int |
deleteByQuery(String tableName,
QueryWrapper queryWrapper)
根据 query 构建的条件来删除数据
|
static int |
deleteBySql(String sql,
Object... args)
编写 delete sql 来删除数据
|
static int |
insert(String tableName,
Row row)
网 tableName 插入一条 row 数据
|
static int[] |
insertBatch(String tableName,
Collection<Row> rows)
批量插入数据
|
static int[] |
insertBatch(String tableName,
Collection<Row> rows,
int batchSize)
批量插入数据
|
static int |
insertBatchWithFirstRowColumns(String tableName,
List<Row> rows)
批量插入数据,根据第一条内容来构建插入的字段,效率比
insertBatch(String, Collection, int) 高 |
static int |
insertBySql(String sql,
Object... args)
直接编写 sql 插入数据
|
static RowMapperInvoker |
invoker() |
static RowMapperInvoker |
invoker(String environmentId) |
static Page<Row> |
paginate(String tableName,
int pageNumber,
int pageSize,
int totalRow,
QueryCondition condition)
分页查询
|
static Page<Row> |
paginate(String tableName,
int pageNumber,
int pageSize,
int totalRow,
QueryWrapper queryWrapper)
分页查询
|
static Page<Row> |
paginate(String tableName,
int pageNumber,
int pageSize,
QueryCondition condition)
分页查询
|
static Page<Row> |
paginate(String tableName,
int pageNumber,
int pageSize,
QueryWrapper queryWrapper)
分页查询
|
static Page<Row> |
paginate(String tableName,
Page<Row> page,
QueryWrapper queryWrapper)
分页查询
|
static List<Row> |
selectAll(String tableName)
查询某张表的所有数据
|
static long |
selectCount(String sql,
Object... args)
查收 count 数据,一般用于 select count(*)...
|
static long |
selectCountByCondition(String tableName,
QueryCondition condition)
根据 condition 条件来查询数量
|
static long |
selectCountByQuery(QueryWrapper queryWrapper)
直接根据 query 来查询数据量
|
static long |
selectCountByQuery(String tableName,
QueryWrapper queryWrapper)
根据 query 构建的条件来查询数据量
|
static List<Row> |
selectListByCondition(String tableName,
QueryCondition condition)
通过 condition 条件来查询数据列表
|
static List<Row> |
selectListByCondition(String tableName,
QueryCondition condition,
int count)
根据 condition 条件来查询数据列表
|
static List<Row> |
selectListByMap(String tableName,
Map<String,Object> whereColumns)
通过 map 构建的条件来查询数据列表
|
static List<Row> |
selectListByMap(String tableName,
Map<String,Object> whereColumns,
int count)
根据 map 构建的条件来查询数据列表
|
static List<Row> |
selectListByQuery(QueryWrapper queryWrapper)
通过 query 来查询数据列表
|
static List<Row> |
selectListByQuery(String tableName,
QueryWrapper queryWrapper)
通过 query 来查询数据列表
|
static List<Row> |
selectListBySql(String sql,
Object... args)
通过 sql 来查询多条数据
|
static Object |
selectObject(String sql,
Object... args)
查询某个内容,数据返回的应该只有 1 行 1 列
|
static List<Object> |
selectObjectList(String sql,
Object... args)
查询某列内容,数据返回应该有 多行 1 列
|
static Row |
selectOneByCondition(String tableName,
QueryCondition condition)
根据 condition 来查询数据
|
static Row |
selectOneById(String tableName,
Row row)
根据 id 来查询 1 条数据
|
static Row |
selectOneById(String tableName,
String primaryKey,
Object id)
根据主键来查询 1 条数据
|
static Row |
selectOneByMap(String tableName,
Map whereColumns)
根据 map 来查询 1 条数据
|
static Row |
selectOneByQuery(QueryWrapper queryWrapper)
直接根据 queryWrapper 查询 1 条数据
|
static Row |
selectOneByQuery(String tableName,
QueryWrapper queryWrapper)
根据 queryWrapper 来查询 1 条数据
|
static Row |
selectOneBySql(String sql,
Object... args)
根据 sql 来查询 1 条数据
|
static boolean |
tx(Supplier<Boolean> supplier)
进行事务操作
|
static boolean |
tx(Supplier<Boolean> supplier,
Propagation propagation) |
static int |
updateBatchById(String tableName,
List<Row> rows)
根据主键来批量更新数据
|
static int |
updateByCondition(String tableName,
Row data,
QueryCondition condition)
根据 condition 来更新数据
|
static int |
updateById(String tableName,
Row row)
根据 id 来更新数据
|
static int |
updateByMap(String tableName,
Row data,
Map<String,Object> whereColumns)
根据 map 构建的条件来更新数据
|
static int |
updateByQuery(String tableName,
Row data,
QueryWrapper queryWrapper)
根据 query 构建的条件来更新数据
|
static int |
updateBySql(String sql,
Object... args)
根据原生 sql 来更新数据
|
private static final Map<String,RowMapperInvoker> INVOKER_MAP
static RowMapperInvoker defaultRowMapperInvoker
public Db()
public static RowMapperInvoker invoker()
public static RowMapperInvoker invoker(String environmentId)
public static int insert(String tableName, Row row)
tableName - 表名row - 数据public static int insertBySql(String sql, Object... args)
sql - sql 内容args - sql 参数public static int[] insertBatch(String tableName, Collection<Row> rows)
tableName - 表名rows - 数据public static int[] insertBatch(String tableName, Collection<Row> rows, int batchSize)
tableName - 表名rows - 数据batchSize - 每次提交的数据量public static int insertBatchWithFirstRowColumns(String tableName, List<Row> rows)
insertBatch(String, Collection, int) 高tableName - 表名rows - 数据public static int deleteBySql(String sql, Object... args)
sql - sql 内容args - 参数public static int deleteById(String tableName, Row row)
Row.ofKey(RowKey, Object) 来进行构建的tableName - 表名row - 主键 和 id值public static int deleteById(String tableName, String primaryKey, Object id)
tableName - 表名primaryKey - 主键字段名称id - 主键值public static int deleteBatchByIds(String tableName, String primaryKey, Collection<?> ids)
tableName - 表名primaryKey - 主键字段名称ids - id 集合public static int deleteByMap(String tableName, Map<String,Object> whereColumns)
tableName - 表名whereColumns - where 条件public static int deleteByCondition(String tableName, QueryCondition condition)
tableName - 表名condition - 条件内容public static int deleteByQuery(String tableName, QueryWrapper queryWrapper)
tableName - 表名queryWrapper - querypublic static int updateBySql(String sql, Object... args)
sql - sql 内容args - sql 参数public static int updateById(String tableName, Row row)
tableName - 表情row - id 及其内容public static int updateByMap(String tableName, Row data, Map<String,Object> whereColumns)
tableName - 表名data - 数据内容whereColumns - where 条件public static int updateByCondition(String tableName, Row data, QueryCondition condition)
tableName - 表名data - 数据condition - 条件public static int updateByQuery(String tableName, Row data, QueryWrapper queryWrapper)
tableName - 表名data - 数据内容queryWrapper - queryWrapper 条件public static int updateBatchById(String tableName, List<Row> rows)
tableName - 表名rows - 还有主键的数据public static Row selectOneBySql(String sql, Object... args)
sql - sql 内容args - sql 参数public static Row selectOneById(String tableName, Row row)
tableName - 表名row - 主键和 id 值public static Row selectOneById(String tableName, String primaryKey, Object id)
tableName - 表名primaryKey - 主键字段名称id - 主键值public static Row selectOneByMap(String tableName, Map whereColumns)
tableName - 表名whereColumns - where条件public static Row selectOneByCondition(String tableName, QueryCondition condition)
tableName - 表名condition - 条件public static Row selectOneByQuery(String tableName, QueryWrapper queryWrapper)
tableName - 表名queryWrapper - queryWrapperpublic static Row selectOneByQuery(QueryWrapper queryWrapper)
queryWrapper - 必须带有 from 的 queryWrapperpublic static List<Row> selectListBySql(String sql, Object... args)
sql - sql 内容args - sql 参数public static List<Row> selectListByMap(String tableName, Map<String,Object> whereColumns)
tableName - 表名whereColumns - where 条件public static List<Row> selectListByMap(String tableName, Map<String,Object> whereColumns, int count)
tableName - 表名whereColumns - 条件count - 数据量public static List<Row> selectListByCondition(String tableName, QueryCondition condition)
tableName - 表名condition - where 条件public static List<Row> selectListByCondition(String tableName, QueryCondition condition, int count)
tableName - 表名condition - 条件count - 数据量public static List<Row> selectListByQuery(String tableName, QueryWrapper queryWrapper)
tableName - 表名queryWrapper - query 条件public static List<Row> selectListByQuery(QueryWrapper queryWrapper)
queryWrapper - 必须带有 from 的 queryWrapperpublic static Object selectObject(String sql, Object... args)
sql - sql 内容args - sql 参数public static List<Object> selectObjectList(String sql, Object... args)
sql - sql 内容args - sql 参数public static long selectCount(String sql, Object... args)
sql - sql 内容args - sql 参数public static long selectCountByCondition(String tableName, QueryCondition condition)
tableName - 表名condition - 条件public static long selectCountByQuery(String tableName, QueryWrapper queryWrapper)
tableName - 表名queryWrapper - query 条件public static long selectCountByQuery(QueryWrapper queryWrapper)
queryWrapper - 必须带有表名的 queryWrapperpublic static Page<Row> paginate(String tableName, int pageNumber, int pageSize, QueryCondition condition)
tableName - 表名pageNumber - 当前的页码pageSize - 每页的数据量condition - 条件public static Page<Row> paginate(String tableName, int pageNumber, int pageSize, int totalRow, QueryCondition condition)
tableName - 表名pageNumber - 当前的页码pageSize - 每页的数据量totalRow - 数据总量condition - 条件public static Page<Row> paginate(String tableName, int pageNumber, int pageSize, QueryWrapper queryWrapper)
tableName - 表名pageNumber - 当前的页码pageSize - 每页的数据量queryWrapper - 条件public static Page<Row> paginate(String tableName, int pageNumber, int pageSize, int totalRow, QueryWrapper queryWrapper)
tableName - 表名pageNumber - 当前的页码pageSize - 每页的数据量totalRow - 数据总量queryWrapper - 条件public static Page<Row> paginate(String tableName, Page<Row> page, QueryWrapper queryWrapper)
tableName - 表名page - page 对象,若 page 有 totalCount 值,则不会再去查询分类的数据总量queryWrapper - 条件public static boolean tx(Supplier<Boolean> supplier, Propagation propagation)
Copyright © 2023. All rights reserved.