public class DefaultNbQuerier<T> extends Object implements NbQuerier<T>
| 限定符和类型 | 字段和说明 |
|---|---|
protected MergeSegments |
expression
条件sql片段(复制mybatis plus)
|
protected String |
lastSql |
protected QueryFields |
queryFields
所有查询字段
|
| 构造器和说明 |
|---|
DefaultNbQuerier(NbQuerierConfiguration configuration)
设置事务,使得所有操作都在一个事务内
todo 事务
|
| 限定符和类型 | 方法和说明 |
|---|---|
NbQuerier<T> |
addConditionAgg(ISqlSegment count,
String alias) |
NbQuerier<T> |
additionField(String field)
添加附加字段
|
NbQuerier<T> |
additionFields(List<String> fields) |
NbQuerier<T> |
addRowNum(String partitionBy,
String orderField,
String sort)
添加行号(一般用于分组查询)
|
NbQuerier<T> |
alias(String alias)
设置主表别名
|
NbQuerier<T> |
autoOrder()
自动排序
排序字段 desc
pk desc
|
NbQuerier<T> |
batch(INbExecuteBatch nbBatch)
批量提交
|
Map<String,Object> |
beanToMap(T bean)
将对象转为map
|
String |
buildConnect(NbQuerier<?> querier)
构建并连接参数
|
String |
buildFuncSql(String funcName)
构建聚合查询sql
|
String |
buildQuerySql()
构建查询sql
|
<F> List<F> |
column(String field)
查某列数据
|
NbQuerier<T> |
conditionCount(ILaterQuerier laterQuerier,
String alias,
boolean coalesce)
条件聚合
|
String |
connectParam(NbQuerier<?> querier,
String sql)
连接参数
|
int |
count(boolean page) |
int |
delete() |
NbQuerier<T> |
doAfterForItem(Consumer<T> doAfterForItem)
select 之后对item操作
|
NbQuerier<T> |
doAfterForItemMap(Consumer<LinkedHashMap<String,Object>> doAfterForItemMap)
对map处理
|
NbQuerier<T> |
doAfterForList(Consumer<List<T>> doAfter)
select 执行后都对数据处理
|
NbQuerier<T> |
doAfterForMapList(Consumer<List<LinkedHashMap<String,Object>>> doAfter)
查询结果map处理
|
boolean |
exist()
是否存在该记录
|
NbQuerier<T> |
field(String fieldStr)
字段设置
|
T |
find()
查找一个值
|
<F> F |
find(Class<F> clazz)
查找一个对象,自动构建类
|
QueryField |
findField(String fieldName)
查找字段
|
QueryField |
findQueryField(String name) |
QueryField |
findQueryField(String name,
String table)
从表中找字段
|
<F> F |
func(String funcName,
ResultType type,
boolean limit)
替换字段查询
|
DbType |
getDbType()
获取数据库类型
|
String |
getDsName()
获取数据源名称
|
<G,K> String |
getFieldName(SFunction<G,K> function,
boolean withAlias)
解析lambda字段名称
|
String |
getSqlSegment()
SQL 片段
|
NbQuerier<T> |
group(String... columns) |
boolean |
hasWhere()
是否有where条件
|
NbQuerier<T> |
having(String sqlHaving) |
NbQuerier<T> |
last(String last)
加入最后
|
NbQuerier<T> |
leftJoin(Class<?> clazz,
String alias)
自动左连
|
NbQuerier<T> |
leftJoin(Class<?> clazz,
String alias,
String on)
左连接
|
<F,E> NbQuerier<T> |
leftJoin(Class<F> clazz,
String alias,
SFunction<F,E> tableAField,
SFunction<T,E> tableBField)
左连接
|
NbQuerier<T> |
leftJoin(NbQuerier<?> querier,
String alias) |
NbQuerier<T> |
leftJoin(NbQuerier<?> querier,
String alias,
String on,
boolean lateral)
连表子查询
|
NbQuerier<T> |
leftJoin(NbQueryInfo queryInfo,
String on,
boolean lateral) |
NbQuerier<T> |
limit(int offset,
int length)
不同方言的limit方法
|
NbQuerier<T> |
lock()
加锁 其他事务无法获取 该事务查询数据
for update
|
T |
mapToBean(Map<String,Object> map)
结果转换成对象
|
INbExecutor |
newExecutor() |
NbQuerier<T> |
not()
not 连接
|
NbQuerier<T> |
or()
or 连接
|
NbQuerier<T> |
order(NbOrderType sort,
NullsPosition nullsPosition,
String... fields) |
NbQuerier<T> |
page(int pageNo,
int pageSize) |
String |
parseSqlParam(String sql,
QueryValParam... params)
替换sql参数
|
List<ConditionAgg> |
safeGetConditionAggList() |
UpdateData |
safeGetUpdateData() |
int |
save(Map<String,Object> data)
保存数据
|
int |
saveBatchMap(List<Map<String,Object>> dataList)
批量保存
|
List<T> |
select()
执行查询
|
<F> List<F> |
select(Class<F> clazz)
自定义class返回
|
List<LinkedHashMap<String,Object>> |
selectMap()
查询通用map
|
List<LinkedHashMap<String,Object>> |
selectMapList()
查询为map
|
LinkedHashMap<String,Object> |
selectOne(boolean assertOne)
查询一个值
|
NbQuerier<T> |
set(String field,
Object value)
设置更新数据
|
NbQuerier<T> |
setConnection(Connection connection)
设置链接
|
void |
setQueryInfo(NbQueryInfo nbQueryInfo) |
double |
sum(String field)
求和
|
NbQuerier<T> |
tableSchema(String schema)
指定主表的schema
|
NbQuerier<T> |
union(NbQuerier<T> querier) |
NbQuerier<T> |
unionAll(NbQuerier<T> querier) |
int |
update(boolean isDelete) |
NbQuerier<T> |
updateExpr(String expr)
设置表达式更新
|
NbQuerier<T> |
updateExpr(String sql,
Object... params) |
NbQuerier<T> |
where(Consumer<NbQuerier<T>> consumer)
匿名使用wrapper 查询(嵌套查询)
创建一个临时的MergeSegments,替换当前类
|
NbQuerier<T> |
where(IQueryItem iQueryItem,
QueryRuleEnum ruleEnum,
Object value,
boolean notNull) |
NbQuerier<T> |
where(String sql)
直接拼接where语句
重要: 避免直接使用字符串参数拼接,否则会造成sql注入
如需拼接字符串参数,请使用 formatVariable 格式化变量
|
NbQuerier<T> |
where(String field,
QueryRuleEnum ruleEnum,
Object value,
boolean notNull)
where 入口
|
NbQuerier<T> |
where(T t)
将一个对象存在的值作为查询条件,需要注入对象默认值
|
NbQuerier<T> |
whereExists(NbQuerier<?> querier) |
NbQuerier<T> |
whereIn(String field,
NbQuerier<?> querier) |
NbQuerier<T> |
whereNotIn(String field,
NbQuerier<?> querier) |
NbQuerier<T> |
whereOr(Consumer<NbQuerier<T>> consumer) |
NbQuerier<T> |
whereQrs(cn.hutool.json.JSONObject qrs)
qrs 查询json表达式
|
NbQuerier<T> |
withMany(String fieldName,
NbQuerier<?> querier)
查询json数组作为一个字段
|
NbQuerier<T> |
withManyCount(String fieldName,
NbQuerier<?> querier)
查询一对多数量
|
NbQuerier<T> |
withOne(String fieldName,
NbQuerier<?> querier) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddQueryField, allowSetNull, dataPerm, dataScope, dataScope, emptyField, field, field, field, fieldReplace, formatVariable, formatVariable, formatVariable, from, getConditionAggList, getExpression, getJoins, getParams, getTableName, group, leftJoin, leftJoin, newExecutor, order, setResultClass, setTx, startBatch, table, table, table, table, table, table, table, table, updateExpr, updateRemoveArrayItem, view, view, with, with, withDelete, withMany, withMany, withManyCount, withOne, wrapper, wrappercount, sum, totalcolumn, find, findMap, findMap, findMapToCamelCase, selectMapToCamelCaseasc, asc, desc, desc, where, where, where, whereAny, whereAny, whereBt, whereIn, whereIn, whereIn, whereInters, whereLike, whereLikeLeft, whereLikeRight, whereNotAny, whereNotIn, whereNotIn, whereNotNull, whereNull, whereOrNullasc, desc, limit, order, where, where, where, where, whereAny, whereAny, whereExpr, whereIn, whereIn, whereInters, whereLike, whereLikeLeft, whereLikeRight, whereNotAny, whereNotIn, whereNotNull, whereNull, whereOrNull, wherePk, wherePk, whereQrs, whereQrsordergetFieldName, getFieldNames, getPkName, getQueryFields, getQueryInfo, getResultClass, getTableAlias, getTableAliasMap, mapFieldAliasdelete, save, save, saveBatch, saveOrUpdate, saveOrUpdate, set, set, update, update, updateById, updateByIddoAfterForListMapprotected QueryFields queryFields
protected MergeSegments expression
protected String lastSql
public DefaultNbQuerier(NbQuerierConfiguration configuration)
public UpdateData safeGetUpdateData()
public List<ConditionAgg> safeGetConditionAggList()
public void setQueryInfo(NbQueryInfo nbQueryInfo)
public NbQuerier<T> where(Consumer<NbQuerier<T>> consumer)
where 在接口中 DoConditionTopside<T>public NbQuerier<T> whereOr(Consumer<NbQuerier<T>> consumer)
whereOr 在接口中 DefaultDoCondition<T>public NbQuerier<T> whereExists(NbQuerier<?> querier)
whereExists 在接口中 DoConditionTopside<T>public NbQuerier<T> whereIn(String field, NbQuerier<?> querier)
whereIn 在接口中 DoConditionTopside<T>public NbQuerier<T> whereNotIn(String field, NbQuerier<?> querier)
whereNotIn 在接口中 DoConditionTopside<T>public <G,K> String getFieldName(SFunction<G,K> function, boolean withAlias)
getFieldName 在接口中 NbQuerierTopside<T>public NbQuerier<T> or()
DoConditionTopsideor 在接口中 DoConditionTopside<T>public NbQuerier<T> setConnection(Connection connection)
NbQueriersetConnection 在接口中 NbQuerier<T>public NbQuerier<T> batch(INbExecuteBatch nbBatch)
NbQuerierpublic NbQuerier<T> not()
DoConditionTopsidenot 在接口中 DoConditionTopside<T>public NbQuerier<T> where(String sql)
DoConditionTopsidewhere 在接口中 DoConditionTopside<T>public NbQuerier<T> whereQrs(cn.hutool.json.JSONObject qrs)
DoConditionTopsidewhereQrs 在接口中 DoConditionTopside<T>public NbQuerier<T> where(String field, QueryRuleEnum ruleEnum, Object value, boolean notNull)
where 在接口中 DoConditionTopside<T>field - ruleEnum - value - notNull - 是否允许value为空public NbQuerier<T> where(IQueryItem iQueryItem, QueryRuleEnum ruleEnum, Object value, boolean notNull)
where 在接口中 DoConditionTopside<T>public NbQuerier<T> page(int pageNo, int pageSize)
page 在接口中 DefaultDoCondition<T>public NbQuerier<T> limit(int offset, int length)
DoConditionTopsidelimit 在接口中 DoConditionTopside<T>public NbQuerier<T> last(String last)
DoConditionTopsidelast 在接口中 DoConditionTopside<T>public NbQuerier<T> where(T t)
where 在接口中 DoConditionTopside<T>t - public NbQuerier<T> leftJoin(Class<?> clazz, String alias, String on)
NbQuerierpublic <F,E> NbQuerier<T> leftJoin(Class<F> clazz, String alias, SFunction<F,E> tableAField, SFunction<T,E> tableBField)
NbQuerierpublic NbQuerier<T> leftJoin(NbQueryInfo queryInfo, String on, boolean lateral)
public NbQuerier<T> leftJoin(NbQuerier<?> querier, String alias, String on, boolean lateral)
public NbQuerier<T> addRowNum(String partitionBy, String orderField, String sort)
NbQuerierpublic NbQuerier<T> order(NbOrderType sort, @Nullable NullsPosition nullsPosition, String... fields)
order 在接口中 DoConditionTopside<T>public T mapToBean(Map<String,Object> map)
NbQuerierTopsidemapToBean 在接口中 NbQuerierTopside<T>public List<LinkedHashMap<String,Object>> selectMap()
public String buildFuncSql(String funcName)
DoSelectbuildFuncSql 在接口中 DoSelect<T>public String buildQuerySql()
DoSelectbuildQuerySql 在接口中 DoSelect<T>public INbExecutor newExecutor()
@Nullable public QueryField findQueryField(String name, String table)
NbQuerierfindQueryField 在接口中 NbQuerier<T>@Nullable public QueryField findQueryField(String name)
findQueryField 在接口中 NbQuerier<T>public int saveBatchMap(List<Map<String,Object>> dataList)
DoUpdatesaveBatchMap 在接口中 DoUpdate<T>public <F> F func(String funcName, ResultType type, boolean limit)
DoFunctionfunc 在接口中 DoFunction<T>public int count(boolean page)
count 在接口中 DoFunction<T>public NbQuerier<T> conditionCount(ILaterQuerier laterQuerier, String alias, boolean coalesce)
DoFunctionconditionCount 在接口中 DoFunction<T>coalesce - 是否null 替换成0public NbQuerier<T> addConditionAgg(ISqlSegment count, String alias)
addConditionAgg 在接口中 DoFunction<T>public double sum(String field)
DoFunctionsum 在接口中 DoFunction<T>public boolean exist()
DoFunctionexist 在接口中 DoFunction<T>public List<LinkedHashMap<String,Object>> selectMapList()
DoSelectselectMapList 在接口中 DoSelect<T>public boolean hasWhere()
NbQuerierpublic String buildConnect(NbQuerier<?> querier)
buildConnect 在接口中 NbQuerier<T>querier - public String connectParam(NbQuerier<?> querier, String sql)
connectParam 在接口中 NbQuerier<T>querier - sql - public NbQuerier<T> withMany(String fieldName, NbQuerier<?> querier)
NbQuerierpublic NbQuerier<T> withManyCount(String fieldName, NbQuerier<?> querier)
withManyCount 在接口中 NbQuerier<T>fieldName - querier - public NbQuerier<T> updateExpr(String expr)
NbQuerierupdateExpr 在接口中 NbQuerier<T>public NbQuerier<T> updateExpr(String sql, Object... params)
updateExpr 在接口中 NbQuerier<T>public String parseSqlParam(String sql, QueryValParam... params)
DoConditionTopsideparseSqlParam 在接口中 DoConditionTopside<T>public NbQuerier<T> tableSchema(String schema)
NbQueriertableSchema 在接口中 NbQuerier<T>public DbType getDbType()
DoConditionTopsidegetDbType 在接口中 DoConditionTopside<T>public QueryField findField(String fieldName)
NbQuerierpublic NbQuerier<T> additionFields(List<String> fields)
additionFields 在接口中 NbQuerier<T>public NbQuerier<T> additionField(String field)
additionField 在接口中 NbQuerier<T>field - public <F> F find(Class<F> clazz)
public LinkedHashMap<String,Object> selectOne(boolean assertOne)
DoSelectpublic NbQuerier<T> doAfterForMapList(Consumer<List<LinkedHashMap<String,Object>>> doAfter)
IResultMapdoAfterForMapList 在接口中 IResultMap<T>public NbQuerier<T> doAfterForItem(Consumer<T> doAfterForItem)
doAfterForItem 在接口中 IResultMap<T>public NbQuerier<T> doAfterForItemMap(Consumer<LinkedHashMap<String,Object>> doAfterForItemMap)
IResultMapdoAfterForItemMap 在接口中 IResultMap<T>public NbQuerier<T> doAfterForList(Consumer<List<T>> doAfter)
doAfterForList 在接口中 IResultMap<T>doAfter - public String getSqlSegment()
ISqlSegmentgetSqlSegment 在接口中 ISqlSegmentpublic Map<String,Object> beanToMap(T bean)
NbQuerierTopsidebeanToMap 在接口中 NbQuerierTopside<T>Copyright © 2023. All rights reserved.