类 DefaultService<E>
java.lang.Object
org.anyline.service.init.DefaultService<E>
- 所有已实现的接口:
AnylineService<E>
@AnylineComponent(value="anyline.service",
index=10)
public class DefaultService<E>
extends Object
implements AnylineService<E>
-
嵌套类概要
从接口继承的嵌套类/接口 org.anyline.service.AnylineService
AnylineService.AuthorizeService, AnylineService.DDLService, AnylineService.MetaDataService -
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明adapter()cache(String cache, RunPrepare table, ConfigStore configs, Object obj, String... conditions) 如果二级缓存开启 会从二级缓存中提取数据caches(String cache, RunPrepare table, ConfigStore configs, Object obj, String... conditions) protected booleancheckCondition(Object data) protected booleancheckCondition(Object data, ConfigStore configs, String... conditions) update/delete 前检测是否有过滤条件protected booleancheckCondition(ConfigStore configs, String... conditions) booleanclearCache(String channel) 清空缓存boolean清空全部缓存column2param(String table) 列名转找成参数名 可以给condition()提供参数用来接收前端参数longcount(String dest, ConfigStore configs, Object obj, String... conditions) countlongcount(RunPrepare prepare, ConfigStore configs, Object obj, String... conditions) longcount(Table dest, ConfigStore configs, Object obj, String... conditions) createRunPrepare(String src) createRunPrepare(Table table) 相关数据源ddl()ddl(List<MetadataDiffer> differs) 根据差异生成SQLddl(MetadataDiffer differ) 根据差异生成SQLlong根据columns列删除
注意:为了避免整表删除, columns必须提供否则会抛出异常
如果要删除整表需要单独写原生的SQL调用execute(sql)
delete(User/DataRow, "TYPE","AGE")
DELETE FROM USER WHERE TYPE = ?long根据多列条件删除
注意:为了避免整表删除, values必须提供否则会抛出异常
整表删除请调用service.execute("DELETE FROM TAB");或service.truncate("TAB“)
以k, v, k, v或"k:v"形式提供参数
delete("HR_EMPLOYEE","type","1","age:20");
DELETE FROM HR_EMPLOYEE WHERE TYPE = 1 AND AGE = 20
注意以下两咱情况, 并不会忽略空值
service.delete("HR_EMPLOYEE","ID","","CODE:20");
DELETE FROM HR_EMPLOYEE WHERE ID = '' AND CODE = 20
service.delete("HR_EMPLOYEE","ID","1","CODE:");
DELETE FROM HR_EMPLOYEE WHERE ID = 1 AND CODE = ''longdelete(String table, Collection values) longdelete(String table, ConfigStore configs, String... conditions) 根据ConfigStore中的条件+conditions条件删除longlong删除 根据columns列删除 可设置复合主键
注意:为了避免整表删除, columns必须提供否则会抛出异常
如果要删除整表需要单独写原生的SQL调用execute(sql)longlongdelete(Table table, Collection values) longdelete(Table table, ConfigStore configs, String... conditions) longlong<T> longdeletes(int batch, String table, String key, Collection<T> values) 根据一列的多个值删除
注意:为了避免整表删除, values必须提供否则会抛出异常
整表删除请调用service.execute("DELETE FROM TAB");或service.truncate("TAB“)
delete("USER","TYPE", [1, 2, 3])
DELETE FROM USER WHERE TYPE IN(1, 2, 3)<T> long根据一列的多个值删除
注意:为了避免整表删除, values必须提供否则会抛出异常
整表删除请调用service.execute("DELETE FROM TAB");或service.truncate("TAB“)
delete("USER","TYPE","1","2","3")
DELETE FROM USER WHERE TYPE IN(1, 2, 3)<T> longdeletes(int batch, Table table, String key, Collection<T> values) <T> longbooleanbooleanlongexecute(int batch, int vol, String sql, Collection<Object> values) 执行命令
execute(10, sql, List<List<Object>>);
批量执行要求SQL一样longexecute(int batch, String sql, Collection<Object> values) 执行命令
execute(10, sql, List<List<Object>>);
批量执行要求SQL一样longexecute(String src, ConfigStore configs, String... conditions) 执行longexecute(List<RunPrepare> prepares, ConfigStore configs) RunPrepare批量执行 主要是为了保持在同一连接内执行
通常是用prepare来合成比较复杂的的SQL如CREATE VIEW AS prepare.sqlboolean执行存储过程booleanexists(String dest, ConfigStore configs, Object obj, String... conditions) 是否存在boolean只根据主键判断booleanexists(Table dest, ConfigStore configs, Object obj, String... conditions) booleanget(ConfigStore configs, String... conditions) getDao()gets(ConfigStore configs, String... conditions) long插入数据longlonginsert(Table dest, RunPrepare prepare, ConfigStore configs, Object obj, String... conditions) insert into table select * from table 复杂的查询先通过TableBuilder构造查询longinsert into table select * from table 与query参数一致int计算字符串在当前数据库中占用字节数maps(String dest, ConfigStore configs, Object obj, String... conditions) 直接返回Map集合不封装, 不分页maps(RunPrepare prepare, ConfigStore configs, Object obj, String... conditions) 按条件查询maps(Table dest, ConfigStore configs, Object obj, String... conditions) metadata()根据结果集对象获取列结构, 如果有表名应该调用metadata().columns(table);或metadata().table(table).getColumns()解析泛型classparsePrimaryKey(String src, List<String> pks) 解析SQL中指定的主键table(col1, col2)<pk1, pk2><T> EntitySet<T>queries(Class<T> clazz, ConfigStore configs, T entity, String... conditions) <T> EntitySet<T>queries(String dest, Class<T> clazz, ConfigStore configs, T entity, String... conditions) 根据SQL或自定义SQL返回实体<T> EntitySet<T>queries(Table dest, Class<T> clazz, ConfigStore configs, T entity, String... conditions) <T> Tquery(Class<T> clazz, ConfigStore configs, T entity, String... conditions) <T> Tquery(String dest, Class<T> clazz, ConfigStore configs, T entity, String... conditions) <T> Tquery(Table dest, Class<T> clazz, ConfigStore configs, T entity, String... conditions) queryFromCache(String cache, String dest, ConfigStore configs, String... conditions) queryFromCache(String cache, RunPrepare prepare, ConfigStore configs, String... conditions) queryFromCache(String cache, Table dest, ConfigStore configs, String... conditions) protected <T> EntitySet<T>queryFromDao(String dest, Class<T> clazz, ConfigStore configs, String... conditions) queryFromDao(String dest, ConfigStore configs, String... conditions) queryFromDao(RunPrepare prepare, ConfigStore configs, String... conditions) protected <T> EntitySet<T>queryFromDao(Table dest, Class<T> clazz, ConfigStore configs, String... conditions) queryFromDao(Table dest, ConfigStore configs, String... conditions) booleanremoveCache(String channel, String dest, ConfigStore configs, String... conditions) 删除缓存 参数保持与查询参数完全一致booleanremoveCache(String channel, Table dest, ConfigStore configs, String... conditions) <T extends Role>
LinkedHashMap<String,T> roles()当前用户角色runtime()longsave insert区别 操作单个对象时没有区别 在操作集合时区别: save会循环操作数据库每次都会判断insert|update save 集合中的数据可以是不同的表不同的结构 insert 集合中的数据必须保存到相同的表, 结构必须相同 insert 将一次性插入多条数据整个过程有可能只操作一次数据库 并 不考虑update情况 对于大批量数据来说 性能是主要优势 保存(insert|update)根据是否有主键值确定insert或updatelongboolean修改列 名称 数据类型 位置 默认值 执行save前先调用column.update()设置修改后的属性 column.update().setName().setDefaultValue().setAfter()....boolean修改表结构protected longsaveObject(String dest, Object data, ConfigStore configs, String... columns) protected longsaveObject(String dest, Object data, ConfigStore configs, List<String> columns) protected longsaveObject(Table dest, Object data, ConfigStore configs, String... columns) protected longsaveObject(Table dest, Object data, ConfigStore configs, List<String> columns) select(String dest, ConfigStore store, Object obj, String... conditions) select(RunPrepare prepare, ConfigStore store, Object obj, String... conditions) select(Table dest, ConfigStore store, Object obj, String... conditions) protected <T> EntitySet<T>selectFromDao(Class<T> clazz, ConfigStore configs, String... conditions) selects(String dest, ConfigStore configs, Object obj, String... conditions) 按条件查询selects(RunPrepare prepare, ConfigStore configs, Object obj, String... conditions) 按条件查询根据存储过程查询selects(Table dest, ConfigStore configs, Object obj, String... conditions) 查询序列cur 或 next value查询序列cur 或 next valuesetDao(AnylineDao dao) protected PageNavisetPageLazy(String src, ConfigStore configs, String... conditions) protected PageNavisetPageLazy(Table src, ConfigStore configs, String... conditions) longlonglong更新记录 默认情况下以主键为更新条件, 需在更新的数据保存在data中 如果提供了dest则更新dest表, 如果没有提供则根据data解析出表名 DataRow/DataSet可以临时设置主键 如设置TYPE_CODE为主键, 则根据TYPE_CODE更新 可以提供了ConfigStore以实现更复杂的更新条件 需要更新的列通过fixs/columns提供longlongupdate(RunPrepare prepare, DataRow data, ConfigStore configs, String... conditions) 多表关联更新从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 org.anyline.service.AnylineService
aggregation, aggregation, aggregation, aggregation, cache, cache, cache, cache, cache, cache, cache, cache, cache, cache, cache, cache, cache, cache, cache, cache, cache, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, caches, columns, columns, columns, columns, columns, columns, commit, copy, count, count, count, count, count, count, count, count, count, delete, delete, delete, delete, deletes, deletes, deletes, deletes, execute, execute, execute, execute, execute, execute, execute, executeProcedure, exists, exists, exists, exists, exists, exists, exists, get, gets, gets, gets, gets, hit, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, length, maps, maps, maps, maps, maps, maps, maps, maps, maps, maps, maps, maps, maps, maps, maps, maps, maps, maps, maps, maps, maps, maps, maps, maps, maps, maps, maps, maps, maps, maps, maps, maps, maps, masters, masters, masters, masters, masters, masters, masters, masters, masters, metadata, queries, queries, queries, queries, queries, queries, queries, queries, queries, queries, queries, queries, queries, queries, queries, queries, queries, queries, queries, queries, queries, queries, queries, queries, queries, queries, queries, query, query, query, query, query, query, query, query, query, removeCache, removeCache, removeCache, removeCache, rollback, save, save, save, save, save, save, save, save, save, save, save, save, save, save, save, save, save, save, save, save, select, select, select, select, select, select, select, select, select, select, select, selectProcedure, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selects, selectsProcedure, selectsProcedure, selectsProcedure, sequence, sequences, start, start, start, tables, tables, tables, tables, tables, tables, tables, tags, tags, tags, tags, tags, update, update, update, update, update, update, update, update, update, update, update, update, update, update, update, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, upsert, validity, views, views, views, views, views, views, views, views, views
-
字段详细资料
-
log
-
dao
-
metadata
-
ddl
-
authorize
-
-
构造器详细资料
-
DefaultService
public DefaultService()
-
-
方法详细资料
-
datasource
从接口复制的说明:AnylineService相关数据源- 指定者:
datasource在接口中AnylineService<E>- 返回:
- String
-
adapter
- 指定者:
adapter在接口中AnylineService<E>
-
runtime
- 指定者:
runtime在接口中AnylineService<E>
-
getDao
- 指定者:
getDao在接口中AnylineService<E>
-
setDao
- 指定者:
setDao在接口中AnylineService<E>
-
selects
按条件查询- 指定者:
selects在接口中AnylineService<E>- 参数:
dest- 查询或操作的目标(表|视图|函数|自定义SQL | SELECT语句)obj- 根据obj的field/value构造查询条件(支侍Map和Object)(查询条件只支持 =和in)conditions- 查询条件 支持k:v k:v::type 以及原生sql形式(包含ORDER、GROUP、HAVING)默认忽略空值条件configs- 根据http等上下文构造查询条件- 返回:
- DataSet
-
selects
- 指定者:
selects在接口中AnylineService<E>
-
column2param
从接口复制的说明:AnylineService列名转找成参数名 可以给condition()提供参数用来接收前端参数- 指定者:
column2param在接口中AnylineService<E>- 参数:
table- 表 如果不提供表名则根据data解析, 表名可以事实前缀<数据源名>表示切换数据源- 返回:
- List
-
maps
public List<Map<String,Object>> maps(RunPrepare prepare, ConfigStore configs, Object obj, String... conditions) 按条件查询- 指定者:
maps在接口中AnylineService<E>- 参数:
prepare- 构建最终执行命令的全部参数,包含表(或视图|函数|自定义SQL)查询条件 排序 分页等configs- 根据http等上下文构造查询条件obj- 根据obj的field/value构造查询条件(支侍Map和Object)(查询条件只支持 =和in)conditions- 查询条件 支持k:v k:v::type 以及原生sql形式(包含ORDER、GROUP、HAVING)默认忽略空值条件- 返回:
- DataSet
-
maps
public List<Map<String,Object>> maps(String dest, ConfigStore configs, Object obj, String... conditions) 从接口复制的说明:AnylineService直接返回Map集合不封装, 不分页- 指定者:
maps在接口中AnylineService<E>- 参数:
dest- 数据源(表或自定义SQL或SELECT语句)configs- 根据http等上下文构造查询条件obj- 根据obj的field/value构造查询条件(支侍Map和Object)(查询条件只支持 =和in)conditions- 查询条件 支持k:v k:v::type 以及原生sql形式(包含ORDER、GROUP、HAVING)默认忽略空值条件- 返回:
- List
-
maps
public List<Map<String,Object>> maps(Table dest, ConfigStore configs, Object obj, String... conditions) - 指定者:
maps在接口中AnylineService<E>
-
caches
public DataSet<DataRow> caches(String cache, String dest, ConfigStore configs, Object obj, String... conditions) 从接口复制的说明:AnylineService如果二级缓存开启 会从二级缓存中提取数据- 指定者:
caches在接口中AnylineService<E>- 参数:
cache- 对应ehcache缓存配置文件 中的cache.name 如果不指定cache则只在当前线程内有效dest- 查询或操作的目标(表、存储过程、SQL等)configs- 根据http等上下文构造查询条件obj- 根据obj的field/value构造查询条件(支侍Map和Object)(查询条件只支持 =和in)conditions- 查询条件 支持k:v k:v::type 以及原生sql形式(包含ORDER、GROUP、HAVING)默认忽略空值条件- 返回:
- DataSet
-
caches
public DataSet<DataRow> caches(String cache, Table dest, ConfigStore configs, Object obj, String... conditions) - 指定者:
caches在接口中AnylineService<E>
-
select
- 指定者:
select在接口中AnylineService<E>
-
select
- 指定者:
select在接口中AnylineService<E>
-
sequence
从接口复制的说明:AnylineService查询序列cur 或 next value- 指定者:
sequence在接口中AnylineService<E>- 参数:
next- 是否生成返回下一个序列 false:cur true:nextname- 序列名- 返回:
- long 查询失败返回null
-
sequences
从接口复制的说明:AnylineService查询序列cur 或 next value- 指定者:
sequences在接口中AnylineService<E>- 参数:
next- 是否生成返回下一个序列 false:cur true:nextnames- 序列名- 返回:
- DataRow 查询结果按序列名保存到DataRow中,查询失败返回null
-
cache
public DataRow cache(String cache, String dest, ConfigStore configs, Object obj, String... conditions) - 指定者:
cache在接口中AnylineService<E>- 参数:
cache- 对应ehcache缓存配置文件 中的cache.namedest- 查询或操作的目标(表、存储过程、SQL等)configs- 根据http等上下文构造查询条件obj- 根据obj的field/value构造查询条件(支侍Map和Object)(查询条件只支持 =和in)conditions- 查询条件 支持k:v k:v::type 以及原生sql形式(包含ORDER、GROUP、HAVING)默认忽略空值条件- 返回:
- DataSet
-
cache
public DataRow cache(String cache, Table dest, ConfigStore configs, Object obj, String... conditions) - 指定者:
cache在接口中AnylineService<E>
-
queries
public <T> EntitySet<T> queries(Class<T> clazz, ConfigStore configs, T entity, String... conditions) - 指定者:
queries在接口中AnylineService<E>- 类型参数:
T- T- 参数:
clazz- 返回类型configs- 根据http等上下文构造查询条件entity- 根据entity的field/value构造简单的查询条件(支侍Map和Object)(查询条件只支持 =和in)conditions- 查询条件 支持k:v k:v::type 以及原生sql形式(包含ORDER、GROUP、HAVING)默认忽略空值条件- 返回:
- EntitySet
-
query
- 指定者:
query在接口中AnylineService<E>
-
queries
public <T> EntitySet<T> queries(String dest, Class<T> clazz, ConfigStore configs, T entity, String... conditions) 从接口复制的说明:AnylineService根据SQL或自定义SQL返回实体- 指定者:
queries在接口中AnylineService<E>- 类型参数:
T- T- 参数:
dest- SQL或自定义SQLclazz- 返回类型configs- 根据http等上下文构造查询条件entity- 根据entity的field/value构造简单的查询条件(支侍Map和Object)(查询条件只支持 =和in)conditions- 查询条件 支持k:v k:v::type 以及原生sql形式(包含ORDER、GROUP、HAVING)默认忽略空值条件- 返回:
- EntitySet
-
queries
public <T> EntitySet<T> queries(Table dest, Class<T> clazz, ConfigStore configs, T entity, String... conditions) - 指定者:
queries在接口中AnylineService<E>
-
query
public <T> T query(String dest, Class<T> clazz, ConfigStore configs, T entity, String... conditions) - 指定者:
query在接口中AnylineService<E>
-
query
- 指定者:
query在接口中AnylineService<E>
-
parseGenericClass
解析泛型class- 返回:
- class
-
gets
- 指定者:
gets在接口中AnylineService<E>
-
get
- 指定者:
get在接口中AnylineService<E>
-
selects
public DataSet<DataRow> selects(RunPrepare prepare, ConfigStore configs, Object obj, String... conditions) 按条件查询- 指定者:
selects在接口中AnylineService<E>- 参数:
prepare- 构建最终执行命令的全部参数,包含表(或视图|函数|自定义SQL)查询条件 排序 分页等configs- 根据http等上下文构造查询条件obj- 根据obj的field/value构造查询条件(支侍Map和Object)(查询条件只支持 =和in)conditions- 查询条件 支持k:v k:v::type 以及原生sql形式(包含ORDER、GROUP、HAVING)默认忽略空值条件- 返回:
- DataSet
-
caches
public DataSet<DataRow> caches(String cache, RunPrepare table, ConfigStore configs, Object obj, String... conditions) - 指定者:
caches在接口中AnylineService<E>- 参数:
cache- 缓存 channeltable- 构建最终执行命令的全部参数,包含表(或视图|函数|自定义SQL)查询条件 排序 分页等configs- 过滤条件及相关配置obj- 根据obj的field/value构造查询条件(支侍Map和Object)(查询条件只支持 =和in)conditions- 查询条件 支持k:v k:v::type 以及原生sql形式(包含ORDER、GROUP、HAVING)默认忽略空值条件- 返回:
- DataSet
-
select
- 指定者:
select在接口中AnylineService<E>
-
cache
public DataRow cache(String cache, RunPrepare table, ConfigStore configs, Object obj, String... conditions) - 指定者:
cache在接口中AnylineService<E>- 参数:
cache- 缓存 channeltable-configs- 过滤条件及相关配置obj- 根据obj的field/value构造查询条件(支侍Map和Object)(查询条件只支持 =和in)conditions- 查询条件 支持k:v k:v::type 以及原生sql形式(包含ORDER、GROUP、HAVING)默认忽略空值条件- 返回:
- DataRow
-
removeCache
删除缓存 参数保持与查询参数完全一致- 指定者:
removeCache在接口中AnylineService<E>- 参数:
channel- channeldest- 查询或操作的目标(表、存储过程、SQL等)configs- configsconditions- conditions- 返回:
- boolean
-
removeCache
- 指定者:
removeCache在接口中AnylineService<E>
-
clearCache
清空缓存- 指定者:
clearCache在接口中AnylineService<E>- 参数:
channel- channel- 返回:
- boolean
-
clearCaches
public boolean clearCaches()从接口复制的说明:AnylineService清空全部缓存- 指定者:
clearCaches在接口中AnylineService<E>- 返回:
- boolean
-
exists
是否存在- 指定者:
exists在接口中AnylineService<E>- 参数:
dest- 查询或操作的目标(表、存储过程、SQL等)configs- 根据http等上下文构造查询条件obj- 根据obj的field/value构造查询条件(支侍Map和Object)(查询条件只支持 =和in)conditions- 查询条件 支持k:v k:v::type 以及原生sql形式(包含ORDER、GROUP、HAVING)默认忽略空值条件- 返回:
- boolean
-
exists
- 指定者:
exists在接口中AnylineService<E>
-
exists
只根据主键判断- 指定者:
exists在接口中AnylineService<E>- 参数:
dest- 查询或操作的目标(表、存储过程、SQL等)row- DataRow- 返回:
- boolean
-
exists
- 指定者:
exists在接口中AnylineService<E>
-
count
count- 指定者:
count在接口中AnylineService<E>- 参数:
dest- 表或视图或自定义SQLconfigs- 过滤条件obj- 根据obj生成的过滤条件conditions- 查询条件 支持k:v k:v::type 以及原生sql形式(包含ORDER、GROUP、HAVING)默认忽略空值条件- 返回:
- long
-
count
- 指定者:
count在接口中AnylineService<E>
-
count
- 指定者:
count在接口中AnylineService<E>
-
length
从接口复制的说明:AnylineService计算字符串在当前数据库中占用字节数- 指定者:
length在接口中AnylineService<E>- 参数:
cn- 字符串- 返回:
- int
-
insert
插入数据- 指定者:
insert在接口中AnylineService<E>- 参数:
batch- 批量执行每批最多数量dest- 表 如果不提供表名则根据data解析, 表名可以事实前缀<数据源名>表示切换数据源data- entity或list或DataRow或DataSet重复columns- 需要插入哪些列configs- 插入过程中的配置项,如是否插入空值
IS_UPDATE_NULL_COLUMN:DataRow是否更新nul值的列(针对DataRow)
IS_UPDATE_EMPTY_COLUMN:DataRow是否更新空值的列
IS_INSERT_NULL_COLUMN:DataRow是否插入nul值的列
IS_INSERT_EMPTY_COLUMN:DataRow是否插入空值的列
IS_UPDATE_NULL_FIELD:Entity是否更新nul值的属性(针对Entity)
IS_UPDATE_EMPTY_FIELD:Entity是否更新空值的属性
IS_INSERT_NULL_FIELD:Entity是否更新nul值的属性
IS_INSERT_EMPTY_FIELD:Entity是否更新空值的属性
IS_CHECK_ALL_INSERT_COLUMN:插入集合时是否检测所有条目的列(默认只检测第一行)
IS_CHECK_ALL_UPDATE_COLUMN:更新集合时是否检测所有条目的列(默认只检测第一行)- 返回:
- 影响行数
-
insert
- 指定者:
insert在接口中AnylineService<E>
-
insert
public long insert(Table dest, RunPrepare prepare, ConfigStore configs, Object obj, String... conditions) 从接口复制的说明:AnylineServiceinsert into table select * from table 复杂的查询先通过TableBuilder构造查询- 指定者:
insert在接口中AnylineService<E>- 参数:
dest- 表 table(c1,c2,c3)需要插入的列可以通过addColumn添加到dest中prepare- 一般通过TableBuilder生成查询- 返回:
- 影响行数
-
insert
从接口复制的说明:AnylineServiceinsert into table select * from table 与query参数一致- 指定者:
insert在接口中AnylineService<E>- 参数:
dest- 插入表origin- 查询表configs- 查询条件及相关配置obj- 查询条件conditions- 查询条件 支持k:v k:v::type 以及原生sql形式(包含ORDER、GROUP、HAVING)默认忽略空值条件- 返回:
- 影响行数
-
update
更新记录 默认情况下以主键为更新条件, 需在更新的数据保存在data中 如果提供了dest则更新dest表, 如果没有提供则根据data解析出表名 DataRow/DataSet可以临时设置主键 如设置TYPE_CODE为主键, 则根据TYPE_CODE更新 可以提供了ConfigStore以实现更复杂的更新条件 需要更新的列通过fixs/columns提供- 指定者:
update在接口中AnylineService<E>- 参数:
columns- 需要更新的列dest- 表 如果不提供表名则根据data解析, 表名可以事实前缀<数据源名>表示切换数据源data- 更新的数据及更新条件(如果有ConfigStore则以ConfigStore为准)configs- 更新条件batch- 批量执行每批最多数量- 返回:
- int 影响行数
-
update
- 指定者:
update在接口中AnylineService<E>
-
update
从接口复制的说明:AnylineService多表关联更新- 指定者:
update在接口中AnylineService<E>- 参数:
prepare- 一般通过TableBuilder生成data- K-VariableValue 更新值key:需要更新的列 value:通常是关联表的列用VariableValue表示,也可以是常量configs- 附加过滤条件 通常是在prepare最外层设置conditions- 附加查询条件 支持k:v k:v::type 以及原生sql形式 默认忽略空值条件- 返回:
- 影响行数
-
checkCondition
update/delete 前检测是否有过滤条件- 参数:
data- Entity | DataRowconfigs- ConfigStore- 返回:
- boolean 返回false表示没有过滤条件 应该中断执行
-
checkCondition
-
checkCondition
-
save
save insert区别 操作单个对象时没有区别 在操作集合时区别: save会循环操作数据库每次都会判断insert|update save 集合中的数据可以是不同的表不同的结构 insert 集合中的数据必须保存到相同的表, 结构必须相同 insert 将一次性插入多条数据整个过程有可能只操作一次数据库 并 不考虑update情况 对于大批量数据来说 性能是主要优势 保存(insert|update)根据是否有主键值确定insert或update- 指定者:
save在接口中AnylineService<E>- 参数:
batch- 批量执行每批最多数量dest- 表 如果不提供表名则根据data解析, 表名可以事实前缀<数据源名>表示切换数据源data- 数据columns- 指定更新或保存的列- 返回:
- 影响行数
-
save
- 指定者:
save在接口中AnylineService<E>
-
saveObject
-
saveObject
-
saveObject
-
saveObject
-
execute
从接口复制的说明:AnylineService执行存储过程- 指定者:
execute在接口中AnylineService<E>- 参数:
procedure- 存储过程inputs- 输入参数- 返回:
- 执行是否成功
-
select
- 指定者:
select在接口中AnylineService<E>
-
execute
从接口复制的说明:AnylineService执行命令
execute(10, sql, List<List<Object>>);
批量执行要求SQL一样- 指定者:
execute在接口中AnylineService<E>- 参数:
batch- 大于1时表示批量执行sql- sqlvalues- 如果是批量执行,需要提供一个二维数组- 返回:
- 影响行数批量执行时不准确
-
execute
从接口复制的说明:AnylineService执行命令
execute(10, sql, List<List<Object>>);
批量执行要求SQL一样- 指定者:
execute在接口中AnylineService<E>- 参数:
batch- 大于1时表示批量执行vol- 每行多少个占位符sql- sqlvalues- 如果是批量执行,需要提供一个二维数组- 返回:
- 影响行数批量执行时不准确
-
execute
从接口复制的说明:AnylineService执行- 指定者:
execute在接口中AnylineService<E>- 参数:
src- 查询或操作的目标(表、存储过程、SQL等)configs- configsconditions- conditions- 返回:
- int
-
execute
RunPrepare批量执行 主要是为了保持在同一连接内执行
通常是用prepare来合成比较复杂的的SQL如CREATE VIEW AS prepare.sql- 指定者:
execute在接口中AnylineService<E>- 参数:
prepares- preparesconfigs- ConfigStore其他配置- 返回:
- 影响行数
-
delete
从接口复制的说明:AnylineService删除 根据columns列删除 可设置复合主键
注意:为了避免整表删除, columns必须提供否则会抛出异常
如果要删除整表需要单独写原生的SQL调用execute(sql)- 指定者:
delete在接口中AnylineService<E>- 参数:
dest- 表 如果不提供表名则根据data解析, 表名可以事实前缀<数据源名>表示切换数据源set- 数据columns- 生成删除条件的列, 如果不设置则根据主键删除- 返回:
- 影响行数
-
delete
- 指定者:
delete在接口中AnylineService<E>
-
delete
- 指定者:
delete在接口中AnylineService<E>
-
delete
- 指定者:
delete在接口中AnylineService<E>
-
delete
从接口复制的说明:AnylineService根据columns列删除
注意:为了避免整表删除, columns必须提供否则会抛出异常
如果要删除整表需要单独写原生的SQL调用execute(sql)
delete(User/DataRow, "TYPE","AGE")
DELETE FROM USER WHERE TYPE = ? AND AGE = ?- 指定者:
delete在接口中AnylineService<E>- 参数:
obj- 实体对象或DataRow/Datasetcolumns- 生成删除条件的列, 如果不设置则根据主键删除- 返回:
- 影响行数
-
delete
从接口复制的说明:AnylineService根据多列条件删除
注意:为了避免整表删除, values必须提供否则会抛出异常
整表删除请调用service.execute("DELETE FROM TAB");或service.truncate("TAB“)
以k, v, k, v或"k:v"形式提供参数
delete("HR_EMPLOYEE","type","1","age:20");
DELETE FROM HR_EMPLOYEE WHERE TYPE = 1 AND AGE = 20
注意以下两咱情况, 并不会忽略空值
service.delete("HR_EMPLOYEE","ID","","CODE:20");
DELETE FROM HR_EMPLOYEE WHERE ID = '' AND CODE = 20
service.delete("HR_EMPLOYEE","ID","1","CODE:");
DELETE FROM HR_EMPLOYEE WHERE ID = 1 AND CODE = ''- 指定者:
delete在接口中AnylineService<E>- 参数:
table- 表 如果不提供表名则根据data解析, 表名可以事实前缀<数据源名>表示切换数据源kvs- key-value- 返回:
- 影响行数
-
delete
- 指定者:
delete在接口中AnylineService<E>
-
delete
- 指定者:
delete在接口中AnylineService<E>
-
delete
- 指定者:
delete在接口中AnylineService<E>
-
deletes
从接口复制的说明:AnylineService根据一列的多个值删除
注意:为了避免整表删除, values必须提供否则会抛出异常
整表删除请调用service.execute("DELETE FROM TAB");或service.truncate("TAB“)
delete("USER","TYPE", [1, 2, 3])
DELETE FROM USER WHERE TYPE IN(1, 2, 3)- 指定者:
deletes在接口中AnylineService<E>table- 表 如果不提供表名则根据data解析, 表名可以事实前缀<数据源名>表示切换数据源key- 列values- 值集合- 返回:
- 影响行数
-
deletes
- 指定者:
deletes在接口中AnylineService<E>
-
deletes
从接口复制的说明:AnylineService根据一列的多个值删除
注意:为了避免整表删除, values必须提供否则会抛出异常
整表删除请调用service.execute("DELETE FROM TAB");或service.truncate("TAB“)
delete("USER","TYPE","1","2","3")
DELETE FROM USER WHERE TYPE IN(1, 2, 3)- 指定者:
deletes在接口中AnylineService<E>table- 表 如果不提供表名则根据data解析, 表名可以事实前缀<数据源名>表示切换数据源key- 名values- 值集合- 返回:
- 影响行数
-
deletes
- 指定者:
deletes在接口中AnylineService<E>
-
delete
从接口复制的说明:AnylineService根据ConfigStore中的条件+conditions条件删除- 指定者:
delete在接口中AnylineService<E>- 参数:
table- 表 如果不提供表名则根据data解析, 表名可以事实前缀<数据源名>表示切换数据源configs- 匹配条件conditions- 匹配条件- 返回:
- 影响行数
-
delete
- 指定者:
delete在接口中AnylineService<E>
-
truncate
- 指定者:
truncate在接口中AnylineService<E>
-
truncate
- 指定者:
truncate在接口中AnylineService<E>
-
setPageLazy
-
setPageLazy
-
queryFromDao
protected DataSet<DataRow> queryFromDao(RunPrepare prepare, ConfigStore configs, String... conditions) -
queryFromDao
-
queryFromDao
-
queryFromDao
protected <T> EntitySet<T> queryFromDao(String dest, Class<T> clazz, ConfigStore configs, String... conditions) -
queryFromDao
protected <T> EntitySet<T> queryFromDao(Table dest, Class<T> clazz, ConfigStore configs, String... conditions) -
selectFromDao
-
condition
- 指定者:
condition在接口中AnylineService<E>
-
ddl
根据差异生成SQL- 指定者:
ddl在接口中AnylineService<E>- 参数:
differ- differ- 返回:
- runs
-
ddl
根据差异生成SQL- 指定者:
ddl在接口中AnylineService<E>- 参数:
differs- differs- 返回:
- runs
-
parsePrimaryKey
解析SQL中指定的主键table(col1, col2)<pk1, pk2>- 参数:
src- srcpks- pks- 返回:
- String
-
createRunPrepare
- 指定者:
createRunPrepare在接口中AnylineService<E>
-
createRunPrepare
- 指定者:
createRunPrepare在接口中AnylineService<E>
-
queryFromCache
protected DataSet<DataRow> queryFromCache(String cache, RunPrepare prepare, ConfigStore configs, String... conditions) -
queryFromCache
-
queryFromCache
-
metadata
public LinkedHashMap<String,Column> metadata(String sql, boolean comment, boolean condition) throws Exception 根据结果集对象获取列结构, 如果有表名应该调用metadata().columns(table);或metadata().table(table).getColumns()- 指定者:
metadata在接口中AnylineService<E>- 参数:
sql- sqlcomment- 是否需要列注释condition- 是否需要拼接查询条件, 如果需要会拼接where 1=0 条件- 返回:
- LinkedHashMap
- 抛出:
Exception
-
roles
当前用户角色- 指定者:
roles在接口中AnylineService<E>- 返回:
- roles
- 抛出:
Exception
-
tables
- 指定者:
tables在接口中AnylineService<E>
-
views
- 指定者:
views在接口中AnylineService<E>
-
masters
- 指定者:
masters在接口中AnylineService<E>
-
columns
- 指定者:
columns在接口中AnylineService<E>
-
tags
- 指定者:
tags在接口中AnylineService<E>
-
save
修改表结构- 指定者:
save在接口中AnylineService<E>- 参数:
table- 表- 抛出:
Exception- 异常 SQL异常
-
save
修改列 名称 数据类型 位置 默认值 执行save前先调用column.update()设置修改后的属性 column.update().setName().setDefaultValue().setAfter()....- 指定者:
save在接口中AnylineService<E>- 参数:
column- 列- 抛出:
Exception- 异常 SQL异常
-
drop
- 指定者:
drop在接口中AnylineService<E>- 抛出:
Exception
-
drop
- 指定者:
drop在接口中AnylineService<E>- 抛出:
Exception
-
metadata
- 指定者:
metadata在接口中AnylineService<E>
-
ddl
- 指定者:
ddl在接口中AnylineService<E>
-
authorize
- 指定者:
authorize在接口中AnylineService<E>
-