public class DbTableQueryBase<T extends DbTableQueryBase> extends WhereBase<T> implements ICacheController<DbTableQueryBase>
| 限定符和类型 | 字段和说明 |
|---|---|
protected CacheUsing |
_cache |
protected int |
limit_size |
protected int |
limit_start |
protected int |
limit_top |
| 构造器和说明 |
|---|
DbTableQueryBase(DbContext context) |
| 限定符和类型 | 方法和说明 |
|---|---|
T |
append(String code,
Object... args)
添加无限制代码
|
T |
build(Act1<T> builder)
通过表达式构建自己
|
T |
cacheTag(String tag)
为缓存添加标签
|
T |
caching(ICacheService service)
使用一个缓存服务
|
long |
count()
已过时。
|
long |
count(String code)
已过时。
|
int |
delete()
执行删除,并返回影响行数
|
Command |
deleteAsCmd()
删除编译并返回命令
|
protected DbQuery |
deleteCompile()
删除编译
|
boolean |
exists()
已过时。
|
T |
from(String table)
添加 FROM 语句
|
T |
hint(String hint) |
T |
innerJoin(String table)
添加SQL 内关联语句
|
long |
insert(Act1<IDataItem> dataBuilder)
执行插入并返回自增值,使用dataBuilder构建的数据
|
long |
insert(IDataItem data)
执行插入并返回自增值,使用data数据
|
Command |
insertAsCmd(IDataItem data)
插入编译并获取命令
|
long |
insertBy(IDataItem data,
String conditionFields)
根据约束进行插入
|
protected DbQuery |
insertCompile(IDataItem data)
插入编译
|
<T> boolean |
insertList(Collection<T> valuesList,
Act2<T,DataItem> dataBuilder)
执行批量合并插入,使用集合数据(由dataBuilder构建数据)
|
protected <T extends GetHandler> |
insertList(IDataItem cols,
Collection<T> valuesList) |
boolean |
insertList(List<DataItem> valuesList)
执行批量合并插入,使用集合数据
|
T |
leftJoin(String table)
添加SQL 左关联语句
|
T |
limit(int size)
添加SQL top语句
|
T |
limit(int start,
int size)
添加SQL paging语句
|
T |
log(boolean isLog)
标记是否记录日志
|
T |
on(String code) |
T |
onEq(String column1,
String column2) |
T |
paging(int start,
int size)
添加SQL paging语句
|
T |
rightJoin(String table)
添加SQL 右关联语句
|
IQuery |
select(String columns)
已过时。
|
<T> List<T> |
selectArray(String column) |
Command |
selectAsCmd(String columns) |
protected DbQuery |
selectCompile(String columns) |
long |
selectCount() |
long |
selectCount(String column) |
DataItem |
selectDataItem(String columns) |
DataList |
selectDataList(String columns) |
IPage<DataItem> |
selectDataPage(String columns) |
protected IQuery |
selectDo(String columns) |
boolean |
selectExists() |
<T> T |
selectItem(String columns,
Class<T> clz) |
<T> List<T> |
selectList(String columns,
Class<T> clz) |
Map<String,Object> |
selectMap(String columns) |
List<Map<String,Object>> |
selectMapList(String columns) |
IPage<Map<String,Object>> |
selectMapPage(String columns) |
<T> IPage<T> |
selectPage(String columns,
Class<T> clz) |
SelectQ |
selectQ(String columns) |
Object |
selectValue(String column) |
<T> T |
selectValue(String column,
T def) |
Variate |
selectVariate(String column) |
protected T |
table(String table) |
T |
top(int size)
添加SQL top语句
|
int |
update(Act1<IDataItem> dataBuilder)
执行更新并返回影响行数,使用dataBuilder构建的数据
|
int |
update(IDataItem data)
执行更新并返回影响行数,使用set接口的数据
|
Command |
updateAsCmd(IDataItem data)
更新编译并返回命令
|
int |
updateBy(IDataItem data,
String conditionFields) |
protected DbQuery |
updateCompile(IDataItem data)
更新编译
|
<T> int[] |
updateList(Collection<T> valuesList,
Act2<T,DataItem> dataBuilder,
String conditionFields)
执行批量合并插入,使用集合数据(由dataBuilder构建数据)
|
protected <T extends GetHandler> |
updateList(IDataItem cols,
Collection<T> valuesList,
String conditionFields) |
int[] |
updateList(List<DataItem> valuesList,
String conditionFields)
执行批量合并插入,使用集合数据
|
long |
upsert(IDataItem data,
String conditionFields)
已过时。
|
long |
upsertBy(IDataItem data,
String conditionFields)
使用data的数据,根据约束字段自动插入或更新
|
T |
usingCache(boolean isCache)
是否使用缓存
|
T |
usingCache(int seconds)
使用缓存时间(单位:秒)
|
protected boolean |
usingExpr() |
T |
usingExpr(boolean isUsing)
充许使用$表达式构建sql
|
protected boolean |
usingNull() |
T |
usingNull(boolean isUsing)
充许使用null插入或更新
|
T |
with(String name,
SelectQ select) |
T |
with(String name,
String code,
Object... args)
添加SQL with 语句(要确保数据库支持)
例:db.table("user u")
.with("a","select type num from group by type")
.where("u.type in(select a.type) and u.type2 in (select a.type)")
.selectMapList("u.*");
|
and, and, andBtw, andByAsc, andByDesc, andEq, andGt, andGte, andIf, andIn, andLk, andLt, andLte, andNbtw, andNeq, andNin, andNlk, begin, begin, beginBtw, beginEq, beginGt, beginGte, beginIn, beginLk, beginLt, beginLte, beginNbtw, beginNeq, beginNin, beginNlk, dbType, end, fmtColumn, fmtCondition, fmtMutColumns, fmtObject, fmtSchema, groupBy, having, or, or, orBtw, orderBy, orderByAsc, orderByDesc, orderByDo, orEq, orGt, orGte, orIf, orIn, orLk, orLt, orLte, orNbtw, orNeq, orNin, orNlk, where, where, where, whereBtw, whereEntity, whereEntityIf, whereEq, whereGt, whereGte, whereIf, whereIn, whereLk, whereLt, whereLte, whereMap, whereMapIf, whereNbtw, whereNeq, whereNin, whereNlk, whereTrueprotected int limit_start
protected int limit_size
protected int limit_top
protected CacheUsing _cache
public DbTableQueryBase(DbContext context)
public T log(boolean isLog)
public T with(String name, String code, Object... args)
例:db.table("user u") .with("a","select type num from group by type") .where("u.type in(select a.type) and u.type2 in (select a.type)") .selectMapList("u.*");
public long insert(Act1<IDataItem> dataBuilder) throws SQLException
SQLExceptionpublic long insert(IDataItem data) throws SQLException
SQLExceptionpublic long insertBy(IDataItem data, String conditionFields) throws SQLException
SQLExceptionpublic boolean insertList(List<DataItem> valuesList) throws SQLException
SQLExceptionpublic <T> boolean insertList(Collection<T> valuesList, Act2<T,DataItem> dataBuilder) throws SQLException
SQLExceptionprotected <T extends GetHandler> boolean insertList(IDataItem cols, Collection<T> valuesList) throws SQLException
SQLException@Deprecated public long upsert(IDataItem data, String conditionFields) throws SQLException
请改用 upsertBy
SQLExceptionpublic long upsertBy(IDataItem data, String conditionFields) throws SQLException
SQLExceptionpublic int updateBy(IDataItem data, String conditionFields) throws SQLException
SQLExceptionpublic int update(Act1<IDataItem> dataBuilder) throws SQLException
SQLExceptionpublic int update(IDataItem data) throws SQLException
SQLExceptionpublic int[] updateList(List<DataItem> valuesList, String conditionFields) throws SQLException
SQLExceptionpublic <T> int[] updateList(Collection<T> valuesList, Act2<T,DataItem> dataBuilder, String conditionFields) throws SQLException
SQLExceptionprotected <T extends GetHandler> int[] updateList(IDataItem cols, Collection<T> valuesList, String conditionFields) throws SQLException
SQLExceptionpublic int delete()
throws SQLException
SQLExceptionpublic Command deleteAsCmd()
protected DbQuery deleteCompile()
public T limit(int start, int size)
public T limit(int size)
public T paging(int start, int size)
public T top(int size)
@Deprecated public boolean exists() throws SQLException
SQLException@Deprecated public long count() throws SQLException
SQLException@Deprecated public long count(String code) throws SQLException
SQLException@Deprecated public IQuery select(String columns)
public boolean selectExists()
throws SQLException
SQLExceptionpublic long selectCount()
throws SQLException
SQLExceptionpublic long selectCount(String column) throws SQLException
SQLExceptionpublic Variate selectVariate(String column) throws SQLException
SQLExceptionpublic Object selectValue(String column) throws SQLException
SQLExceptionpublic <T> T selectValue(String column, T def) throws SQLException
SQLExceptionpublic <T> T selectItem(String columns, Class<T> clz) throws SQLException
SQLExceptionpublic <T> List<T> selectList(String columns, Class<T> clz) throws SQLException
SQLExceptionpublic <T> IPage<T> selectPage(String columns, Class<T> clz) throws SQLException
SQLExceptionpublic DataItem selectDataItem(String columns) throws SQLException
SQLExceptionpublic DataList selectDataList(String columns) throws SQLException
SQLExceptionpublic IPage<DataItem> selectDataPage(String columns) throws SQLException
SQLExceptionpublic Map<String,Object> selectMap(String columns) throws SQLException
SQLExceptionpublic List<Map<String,Object>> selectMapList(String columns) throws SQLException
SQLExceptionpublic IPage<Map<String,Object>> selectMapPage(String columns) throws SQLException
SQLExceptionpublic <T> List<T> selectArray(String column) throws SQLException
SQLExceptionprotected boolean usingNull()
public T usingNull(boolean isUsing)
protected boolean usingExpr()
public T usingExpr(boolean isUsing)
public T caching(ICacheService service)
caching 在接口中 ICacheController<DbTableQueryBase>public T usingCache(boolean isCache)
usingCache 在接口中 ICacheController<DbTableQueryBase>public T usingCache(int seconds)
usingCache 在接口中 ICacheController<DbTableQueryBase>public T cacheTag(String tag)
cacheTag 在接口中 ICacheController<DbTableQueryBase>Copyright © 2023. All rights reserved.