diff --git a/2.0-sharding.md b/2.0-sharding.md index 9bedb669da8c8a77c44b7d8c12eb36b2c5276b62..e8f072f89f66848f1e402549684b550c93972f16 100644 --- a/2.0-sharding.md +++ b/2.0-sharding.md @@ -34,7 +34,7 @@ 1.读写分离 (V1.8已实现) 读写分离,每个库都一样(表都一样,只是部署在不同的节点,如ip不一样)。 从应用的角度来说,需要对读(select、show、explain等)、写(insert、update、delete等)操作进行区分。如果是写操作,就走主库,主库会将数据同步给从库;之后有读操作,就走从库, -从多个slave中选择一个,查询数据。 +从多个从库中选择一个,查询数据。 1)写操作走主库,从操作走多个读库; 2)如果一个事务中同时包含了读请求(如select)和写请求(如insert),则统一走主库(避免分布式事务问题)。 很强的一致性场景时,可以主动要求,进行从库的同步吗? @@ -48,7 +48,7 @@ 读写分离优点 避免单点故障。 -负载均衡,读能力水平扩展。通过配置多个slave节点,可以有效的避免过大的访问量对单个库造成的压力。 +负载均衡,读能力水平扩展。通过配置多个从库节点,可以有效的避免过大的访问量对单个库造成的压力。 在读写分离的情况下,应用需要对读sql/写sql进行区分,读sql走从库,写sql走主库,并考虑主从同步延迟、高可用等一系列问题。 @@ -110,7 +110,7 @@ Apache ShardingSphere 使用 ThreadLocal 管理分片键值。可以通过编程 最终一致性的柔性事务代替强一致事务。 从应用的角度来说,需要对读(select、show、explain等)、写(insert、update、delete等)操作进行区分。如果是写操作,就走主库,主库会将数据同步给从库;之后有读操作,就走从库, -从多个slave中选择一个,查询数据。 +从多个从库中选择一个,查询数据。 事务问题。如果一个事务中同时包含了读请求(如select)和写请求(如insert),如果读请求走从库,写请求走主库,由于跨了多个库,那么jdbc本地事务已经无法控制,属于分布式事务的范畴。而分布式事务非常复杂且效率较低。因此对于读写分离, 目前主流的做法是,事务中的所有sql统一都走主库,由于只涉及到一个库,jdbc本地事务就可以搞定。 diff --git a/Bee-architecture-EN-V1.11.png b/Bee-architecture-EN-V1.11.png new file mode 100644 index 0000000000000000000000000000000000000000..e641860b6116855c7c691181d80869963cabc9fc Binary files /dev/null and b/Bee-architecture-EN-V1.11.png differ diff --git a/Bee-architecture-V1.11.png b/Bee-architecture-V1.11.png new file mode 100644 index 0000000000000000000000000000000000000000..8bc1c80a1a5298e1b7cfdb8b1f99ed52aa5e0a60 Binary files /dev/null and b/Bee-architecture-V1.11.png differ diff --git a/Bee-architecture.png b/Bee-architecture.png deleted file mode 100644 index b985af0e0afb8793f311e4f31ea18f7195196d81..0000000000000000000000000000000000000000 Binary files a/Bee-architecture.png and /dev/null differ diff --git a/Changed_Log.md b/Changed_Log.md index 61704cf358760a492ef56f5c93cf68f8d01ce217..562314a84d034ec3da65f558aaf6fdbd3b67ef7d 100644 --- a/Changed_Log.md +++ b/Changed_Log.md @@ -272,4 +272,102 @@ fix null bug in create() of ObjectCreatorFactory. fix bug for max column number(excel in bee-ext). fix bug about HoneyContext fix bug about checkPackageByClass -fix bug about multi-thread safe in ConditionHelper. \ No newline at end of file +fix bug about multi-thread safe in ConditionHelper. + +**V1.11** +V1.11.0.1.1(**2022 New Year**) +SuidRich add method: + public long insertAndReturnId(T entity,IncludeType includeType); +PreparedSql add method: + public List select(String sql,T returnType); +add annotation PrimaryKey +MapSqlKey support PrimaryKey +BF is shortcut for BeeFactoryHelper +Enhance:config info add trim() about multi-DataSource Write/Read +fix a bug for naming transfer + +V1.11.0.2.1(**2022 Spring Festival**) +add function: Interceptor、multi-tenant +add Interceptor,InterceptorChain +add DefaultInterceptor,CommInterceptorChain,DefaultInterceptorChain + +V1.11.0.2.4(**2022 Beijing Winter Olympics**) +level tow ext cache support +Redis cache support +add BeeExtCache,DefaultBeeExtCache +add BeeExtRedisCache + +V1.11.0.2.15(**2022 the Lantern Festival**) +add annotation:Datetime,Createtime,Updatetime;JustFetch +add support Jndi DataSource +check MapSqlKey value + +V1.11.0.2.20(**Honor**) +Optimize use different Database Type at same time(multi-Ds) +Support use differnt type Database at the same time(eg:use Mysql,Oracle,SQL Server at same time) +PreparedSql,MapSuid support Interceptor +Suid,PreparedSql,MapSuid support get DataSource,get InterceptorChain +Suid,PreparedSql,MapSuid,MoreTable add method:setDataSourceName,getDataSourceName,getInterceptorChain +add Annotation: +AnnotationHandler,AutoSetString +Desensitize +ReplaceInto,MySQL replace into +MultiTenancy +BeforeReturnAnnotationHandler,AbstractDictI18nDefaultHandler +Dict +DictI18n + +V1.11.0.2.28 (**Special Day**) +add ShardingStruct prepare for sharding. +add Column annotation support to extend mapping column and Javabean field name. +support custom TypeHandler,and process the ResultSet. +PreparedSql custom sql support more table select,and return more table struct Javabean. +fixed bug: +More table self association query of the same entity forbid multi-self-cycles + +V1.11.0.3.8 (**Lady First**) +add SetParaTypeConvert for convert PreparedStatement parameter. +Javabean use java.util.Date type for SUID compatibility processing. +SQLite get the timestamp result for conversion. +The Json field of DB is automatically converted to the attribute marked with Json annotation of Javabean(Javabean structure corresponding to Json). + +V1.11.0.3.12 (**Tree Planting Day**) +Ddl.java uses Javabean to create tables, supports the mapping between Java and DB field types, and supports the setting java_dbtype mapping. +Ddl.java is compatible with raw char type and java.util.Date. +PreparedSql support batch insert. +Support Suid instance set NameTranslate. +Add DbFeature Registry,it is easy for setting custom database dialect. +Support Cassandra. + +V1.11.0.3.20 (**Spring Equinox**) +add Custom dynamic SQL token,@in,@toIsNULL1,@toIsNULL2,<if isNotNull>,<if isNotBlank>. +dynamic SQL list transfer list to SQL in eg:in (1,2,3),no need foreach;batch insert also no need foreach. +Separate CN and EN API. + +V1.11.0.4.22 (**The World Earth Day**) +Add registry interface; Add nameregistry. +Change serializer throws exceptions type. +Mapsuid and mapsql support parsing string to boolean type. +Genbean, which does not support JDBC type, reminds you which file to set; +Genbean support config where override the old file; +Genbean support gen javabean's field file; +SuidRich's method selectString support variable-length arguments: + public List selectString(T entity,String... selectFields); +CommInterceptorChain check whether add same class. +SystemLogger supports setting log level to facilitate development and debugging. +The logger add method: public static void debug (string MSG, throwable T) (convenient for development and debugging). +Nocache add log prompt. +Improve cache security. +Add preload SPI interface Preload. +Add InterceptorChainRegistry, an interceptor registrar for global use. +Add configuration item: +pagingWithLimitOffset +notCatchModifyDuplicateException +notShowModifyDuplicateException +fixed bug for type converter. +fixed bug about @PrimaryKey in Suid update(entity). + +V1.11.0.4.29 +The configuration file supports multi-environment differentiated configuration. +SuidRich,public int update(T oldEntity, T newEntity) Interceptors only handle newEntity. + diff --git a/Changed_Log_CN.md b/Changed_Log_CN.md index afdb8f1d000cbeecbc06438fb789e7e528053e7e..3a2aaf11d79b70b3a7e54b363d6ecbcac76cd3f8 100644 --- a/Changed_Log_CN.md +++ b/Changed_Log_CN.md @@ -230,6 +230,7 @@ public Condition opOn(String field, Op Op, Object value); MapSuid(不用Javabean实体结构操作数据库): 新增update,count,查询分页,新增和调整insert and insertAndReturnId. +至此,MapSuid的select,update,insert,delete及分页功能已完备. add method putNew(String fieldName, Object newValue),putNew(Map map),put(Map map),support page in MapSql. add method count(MapSql mapSql),update(MapSql mapSql),insertAndReturnId(MapSql mapSql),support page in MapSuid. add method putNew(String fieldName, Object newValue),putNew(Map map),put(Map map),support page in MapSqlImpl. @@ -261,4 +262,108 @@ fix bug about HoneyContext. fix bug about checkPackageByClass. fix bug about multi-thread safe in ConditionHelper. +**V1.11** +V1.11(**劳动节版**) 五一前更新到Maven +各细分版本添加功能如下: + +V1.11.0.1.1(**2022新年版**) +SuidRich增加方法: + public long insertAndReturnId(T entity,IncludeType includeType); +PreparedSql增加方法: + public List select(String sql,T returnType); +增加声明主键支持: + add annotation PrimaryKey + MapSqlKey support PrimaryKey +可用BF代替BeeFactoryHelper加快输入 +增强:读写模式配置信息去除空格 +fix a bug for naming transfer + +V1.11.0.2.1(**2022春节版**) +拦截器、多租户 +add Interceptor,InterceptorChain +add DefaultInterceptor,CommInterceptorChain,DefaultInterceptorChain + +V1.11.0.2.4(**2022北京冬奥会版**) +二级缓存扩展支持 +Redis缓存支持 +add BeeExtCache,DefaultBeeExtCache +add BeeExtRedisCache + +V1.11.0.2.15(**2022元宵节版**) +添加注解:Datetime,Createtime,Updatetime;JustFetch +添加Jndi数据源支持 +检测MapSqlKey的值 + +V1.11.0.2.20(**荣耀**) +multi-DS同时使用不同类型DB优化 +支持同时使用多种数据库(如同时使用Mysql,Oracle,SQL Server) +PreparedSql(自定义sql),MapSuid:拦截器,多数据源支持 +Suid,PreparedSql,MapSuid支持设置数据源名称,获取拦截器链 +Suid,PreparedSql,MapSuid,MoreTable增加方法:setDataSourceName,getDataSourceName,getInterceptorChain +增加注解: +AnnotationHandler,AutoSetString自动设置字符值 +Desensitize,敏感信息模糊处理 +ReplaceInto,MySQL replace into转换 +MultiTenancy多租户 +BeforeReturnAnnotationHandler,AbstractDictI18nDefaultHandler +Dict字典转化 +DictI18n多语言国际化字典转化 + +V1.11.0.2.28 (**Special Day**) +增加ShardingStruct为分库分表作准备 +Column列名与属性名映射扩展支持 +支持自定义TypeHandler,处理查询的ResultSet结果 +PreparedSql自定义sql支持多表查询,返回多表关联Javabean结构数据 +fixed bug: +多表查询同一个实体自我关联查询禁止自我多次循环 + +V1.11.0.3.8 (**Lady First**) +增加SetParaTypeConvert转化PreparedStatement参数. +Javabean使用java.util.Date类型,进行SUID作兼容处理. +SQLite获取Timestamp结果作转化处理. +实体属性是Javabean与DB表Json类型字段在参数设置与查询结果时自动转换(使用Json注解自定义实现). + +V1.11.0.3.12 (**植树节版**) +Ddl.java使用Javabean创建表,支持追加java与db字段类型映射,支持设置某个DB的java_dbtype类型映射. +Ddl.java兼容原生char类型,兼容java.util.Date. +PreparedSql自定义sql支持批量插入. +支持在Suid等对象设置命名转换器. +增加DbFeature方言注册器,自定义实现不同DB方言更加易用. +支持Cassandra. +showExecutableSql添加List,Set,Map,UUID支持. + +V1.11.0.3.20 (**春分**) +自定义动态SQL标签,@in,@toIsNULL1,@toIsNULL2,<if isNotNull>,<if isNotBlank>. +动态sql,将list转为像in (1,2,3)的语句,不需要foreach,批量插入也不需要foreach. +分离中文API. + +V1.11.0.4.22 (**世界地球日**) +增加Registry空接口;增加NameRegistry. +更改Serializer接口抛出异常方式. +MapSuid,MapSql支持解析字符串的Boolean类型. +GenBean,还不支持的jdbc类型,提醒在哪个文件设置. +GenBean增加支持是否覆盖原有文件设置. +GenBean增加获取字段支持,使用字段名可以不直接使用字符串. +SuidRich的selectString方法支持可变参数: + public List selectString(T entity,String... selectFields); +CommInterceptorChain增加检测是否添加了相同类型拦截器. +systemLogger支持设置日志级别,方便开发调试. +Logger增加public static void debug(String msg,Throwable t)(方便开发调试). +nocache增加日志提示. +提高缓存安全. +添加SPI预加载接口PreLoad. +添加用于全局的拦截器注册器InterceptorChainRegistry. +添加配置项: +是否是limit offset语法分页 pagingWithLimitOffset +是否捕获单条插入时的重复键异常 notCatchModifyDuplicateException +是否显示单条插入时的重复键异常 notShowModifyDuplicateException +fixed bug for type converter. +fixed bug about @PrimaryKey in Suid update(entity). + +V1.11.0.4.29 +配置文件支持多环境差异化配置. +SuidRich,public int update(T oldEntity, T newEntity)拦截器只处理新实体newEntity. + + + \ No newline at end of file diff --git a/FAQ_CN.md b/FAQ_CN.md index eae69ea97c54c08ab67a176cfae2f38727bb7c4b..64e6704940a160f0dbb6248bf17e17e953e008a2 100644 --- a/FAQ_CN.md +++ b/FAQ_CN.md @@ -58,7 +58,7 @@ A: bee更接近原生SQL,可用原生语句分页,不需要全部查出来, Q: Bee怎么具有AI特性? -A: 通过从手工写sql语句直接用JDBC操作数据库,到简单的DB工具类, 再到像Hibernate的旧版本通过操作对象将操作DB封闭到Dao; 再到后来写dao都觉得累赘,通用操作只写个空接口。 ORM工具的发展,就是一步一提炼,简化操作的历史。 假如用AI学习,演变,那写空接口都会觉得是多余的, 每个数据库表不就是表名,以及包含一些列而矣吗??!!! 为什么不能用同样的方式去处理呢??!!! 而且dao层可以直接去掉放到ORM框架统一处理。 为了实现这些目标,就有了Bee框架。 原来编码复杂度是O(n)的,现在变成是O(1),无论多少个表,你都可以不用另外再写dao代码。 可以用时间复杂度和空间复杂度体会下编码复杂度这种变化。 +A: 通过从手工写sql语句直接用JDBC操作数据库,到简单的DB工具类, 再到像Hibernate的旧版本通过操作对象将操作DB封闭到Dao; 再到后来写dao都觉得累赘,通用操作只写个空接口。 ORM工具的发展,就是一步步提炼,简化操作的历史。 假如用AI学习,演变,那写空接口都会觉得是多余的, 每个数据库表不就是表名,以及包含一些列而矣吗??!!! 为什么不能用同样的方式去处理呢??!!! 而且dao层可以直接去掉放到ORM框架统一处理。 为了实现这些目标,就有了Bee框架。 原来编码复杂度是O(n)的,现在变成是O(1),无论多少个表,你都可以不用另外再写dao代码。 可以用时间复杂度和空间复杂度体会下编码复杂度这种变化。 8. @@ -170,11 +170,16 @@ updateById(T entity,Condition condition); A: ORM Bee框架是采用接口与实现分离的设计方式.Bee是接口,而Honey则是Bee的实现. +14-2. Q: Bee开源的代码都是接口定义吗 没有实现吗? + +A: 接口与实现分离. 使用API可只关注接口. +Bee是接口, Honey是实现, Bee-ext是涉及第三方的扩展实现(可能会用到) + 15. Q: Bee非常易用,编写代码少,但使用是一方面, 它的性能如何? -A: 性能绝对是过得去的.README给出了详细的表格比较数据.  详细比较还开启了一个项目,欢迎PK。 +A: 性能绝对是过得去的,接近JDBC的性能.README给出了详细的表格比较数据.  详细比较还开启了一个项目,欢迎PK。 https://gitee.com/automvc/orm-compare 16. @@ -189,7 +194,8 @@ A: Bee文件小。bee V1.8 jar files 仅217k. 而且性能也接近JDBC的性能 Q: 如何自动填日期字段? A: Bee默认不解析是null或空的字段; -当Javabean的日期是null时,Bee不会解析. 像mysql可以在DB端自动触发填充日期值。 +当Javabean的日期是null时,Bee不会解析. 像mysql可以在DB端自动触发填充日期值。 +另外,V1.11增加了相关注解:Datetime,Createtime,Updatetime; 18. @@ -289,6 +295,8 @@ More SQL Function, more Group by } ``` +V1.11可以在Javabean字段上使用JustFetch,表示只是用于获取数据.具体参考JustFetch用法。 + 22. Q: Bee为什么没有findAll(),deleteAll()方法? @@ -310,7 +318,7 @@ A: 别的ORM框架,将insert与update合为一个save方法,每次操作前 但在很多业务场景,insert与update是明确可以区分开的,特别是在互联网应用。 要是用save反而会降低系统的性能。 - **V1.9.8 , SuidRich有提供save方法。 + **V1.9.8** , SuidRich有提供save方法。 如果可以区分开,建议明确调用insert(entity)或者update(entity),这样更加安全和高效。 24. @@ -318,6 +326,7 @@ A: 别的ORM框架,将insert与update合为一个save方法,每次操作前 Q: Bee为什么不需要写mapper,dao? A: 这是Bee的一大优势,Bee的编码复杂度是O(1). Bee概念简单,易于使用,编码量少。 Bee通过约定优于配置原则,通过封装,已经简化了开发. + 可以更简单,省时省力,即可提高开发效率,又可节约开发成本,何乐而不为呢! 25. @@ -340,6 +349,7 @@ https://gitee.com/automvc/bee-exam/blob/master/src/main/java/org/teasoft/exam/be Q: 联合主键如何查询或更新记录? A: Bee通过约定优于配置原则,约定主键名称是id,这样可以使问题变量简单,处理的效率也更高. 对于一些老的系统,有联合主键的,当作一般查询处理即可,即有两个字段作为主键,要用联合主键时,设置两个属性的值,框架就会负责解析(Suid的update方法,SuidRich的selectById等方法默认是id主键则不适用). + V1.11 可以使用PrimaryKey注解. 28. @@ -379,7 +389,8 @@ A: Suid的update方法,SuidRich的selectById等方法默认是将id为会字段 Q: 表名与实体名、字段名与属性名映射默认提供多种实现,且支持自定义映射规则扩展。 请问这个是怎么设置的,谢谢。 How to set customized NameTranslate? A: 实现NameTranslate接口, 并在NameTranslateHandle类设置setNameTranslat(NameTranslate nameTranslat) - + 当前对象设置,参考第41. + 30. Q: 多表关联时,如何在SQL on部分加表达式,过滤数据? @@ -394,7 +405,7 @@ A: update 不像insert 有批量的接口。 因为用同一条语句可以更 如 update table_name set field1='abc' where field2='aa' and field3='bb', 符合where条件的记录都将被更新. 这种只用一条语句就可以更新多条记录,用SuidRich接口相关的update方法就好. -要是确实要多个update,可以自己写一个循环, 然后用同一个connection连接,提交效率. +要是确实要多个update,可以自己写一个循环, 然后用同一个connection连接,提高效率. beginSameConnection(); //多个update语句 endSameConnection(); @@ -509,7 +520,7 @@ A: 分页实例如下(结合springMVC): @RequestParam(value = "rows", defaultValue = "20", required = false) int rows) { Result result =new Result(); - int total = objSQLRichService.count(orderhistory); //可以用上缓存,提交效率 + int total = objSQLRichService.count(orderhistory); //可以用上缓存,提高效率 List list=objSQLRichService.select(orderhistory, (page-1)*rows, rows); result.setRows(list); result.setTotal(total);//返回的总数据条数,有些前端框架需要. @@ -588,10 +599,22 @@ A: 因为maven只下载了jar包,没有下载源码文件. 39. -Q: PreparedSQL 是否支持多数据源? +Q: PreparedSql 是否支持多数据源? -A: PreparedSQL的方法中带有泛型T的是支持多数据源的; 没带有泛型的,在多数据源场景,会操作默认数据源。 +A: PreparedSql的方法中带有泛型T的是支持多数据源的; 没带有泛型的,在多数据源场景,会操作默认数据源。 +40. + +Q: 自己定义了某种DB的方言,如DB2,如何设置到Bee? + +A: V1.11可以通过DbFeatureRegistry设置,简单易用。 + +41. + +Q: 自己定义的命名转换器,如何设置 ? + +A: 全局NameTranslate设置,参考第29. + V1.11支持在Suid等对象使用setNameTranslate方法设置命名转换器。 其它: diff --git a/README.md b/README.md index d79ee65881810bc98109d9a745843c6654c8099c..dcf8497e1c12092ae259281c0c871652d196b01a 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,6 @@ Bee **Good Feature:** AI, Timesaving/Tasteful, Easy, Automatic (**AiTeaSoft Style**) **Bee** see: https://github.com/automvc/bee -or: -https://gitee.com/automvc/bee ## [中文介绍](../../../bee/blob/master/README_CN.md) [点击链接可查看中文介绍](../../../bee/blob/master/README_CN.md) @@ -20,143 +18,138 @@ jdk1.7+ ## Feature & Function: -**Support many Database**(MySQL,MariaDB,Oracle,H2,SQLite,PostgreSQL,SQL Server and so on) and easily extend。 -**Good performance, close to the speed of JDBC; Small files:Bee V1.8 jar 217k**, **V1.9.5 jar,315k, V1.9.8 jar 310k**。 - -**V1.0** -Single entity(table) Suid (select,update,insert,delete) object-oriented operation. -Automatically generate the Javabean via DB table or view. -Convention-over-configuration:Javabean no annotation,no xml. -Automatically mapping the table column and the Javabean field. -Javabean support the raw type:int,double,and so on. -PreparedStatement support. -Procedure support. -Native SQL support. -Batch operate support. -Transaction support. -Automatic filter the null and empty field for default. -MAX,MIN,SUM,AVG,COUNT support. -Order by,Paging. -Select some field. -Dynamic & random combination of query conditions,no need to prepare the interface in advance; new query requirements, no need to change the query interface. -All Suid(select,update,insert,delete) operation use the same Bee interface,no longer need any new dao interface. -Users/Developer only need to pay attention to the Bee interface. - -...... - -**V1.8** -**Add Distributed Feature:** -1.Add multi-DataSource support(Write/Read, only Split Database). -add multi-DataSource no need change the Java code. -add the route interface of multi-Datasource. -add multi-DataSource route. -add multi-DataSource config. -support refresh multi-DataSource config information. -2.Generate global unique id number in distributed environment. -3.Generate Serial Unique id number in one workid of distributed environment. -Independent clock,workerid can config and easily expand. -Implement algorithms:SerialUniqueId,OneTimeSnowflakeId,PearFlowerId. -Support GenId Factory,and can config the id generator. -4.Gen Serial Unique Id for all Table's Long Id field as primary key. -**Enhance Function:** -5.The same database sub table support, dynamic table name mapping support. -Entity and any table name mapping support. -Suid add one method: -public Suid setDynamicParameter(String para,String value); -add 2 annotation:@Table,@Entity. -6.Use 'for update' lock some select record(s). -public Condition forUpdate() -7.Added support for advanced update set, -Complex query and multi table query support only project some fields. -Add 5 methods in Condition -8.Support show type of data in sql and show ExecutableSql: -bee.osql.showSQL.showType=false -bee.osql.showSQL.showExecutableSql=false -9.Add one method in SuidRich -Add three methods in PreparedSql -10.Oracle DATE column mapping to Timestamp,fix the problem:miss the hour,minute,second in Oracle DATE column. -11.GenFiles support upper case first letter,eg: #{entityName?up1}. -**Fix bug:** -12.fixed cache bug:genkey;clear cache for batch insert. -fixed bug:parse the json has extra comma. -fixed null bug about:PreparedSql's method select(String sql,Object preValues[]). - -**v1.8.15**(2020-10-01 3Festivals) -1.Enhance support for H2,SQLite,PostgreSQL. -2.Enhance page funtion,paging para also use placeholder. -3.Can be used in zero configuration. -4.Enhance PearFlowerId algorithm that it will produce even number with continuous mantissa of 0 when is often not used (there are no such defect in SerialUniqueId and OneTimeSnowflakeId). -5.Enhance Log function. -6.Fixed json transform bug. - -**v1.8.99**(2020-10-25 Double Ninth Festival) -1.Support lower and upper case option for SQL KeyWord. -2.Cache sql key support MD5 string. -3.Optimize the way of setting DB information with Honeyconfig. -4.Fix bug about checkSelectField. - -**V1.9** -(just a part) -more table join select support more join condition. -same Connection for some ORM operation. -support different type muli-Ds at same time. -IncludeType support exclude " ". -add Ignore Annotation, ignore the field which do not want to transfer. -support define start and end token when generate file by template. -enhance DB conn management. -enhance code quality(The test coverage is more than 70%, and the key code is more than 90%). -enhance chain coding:Select,Update. -adjust config information of bee.properties,HoneyConfig. -Bee integration with Spring Boot,provide bee-spring-boot-starter. -support use Javabean create the DB table. -fix the problem that the fields with the same name will be confused in some databases(oracle) when multi table paging query. -fixed: update is default by id,but no id field or id is null,will have exception. -fixed: cache bug. -fixed: about getRangeId(int sizeOfIds) of GenId. -fixed: in jdk 11,LoggerFactory use log4j2,have exception. -when entity is view(not table), recommend put in bee.osql.cache.never(bee.properties). - -**V1.9.8**(2021 Mid-Autumn Day) -SuidRich add 4 method: -public int save(T entity); -public int update(T oldEntity,T newEntity); -public String selectJson(T entity, String selectField); -public String selectJson(T entity, String selectField, int start, int size); - -MoreTable(more table select): -support List type field for more tables join; -support two sub tables join(inner join,right join, left join); -support one sub table have another join sub table; -if all fields is null, the sub table field will set null; -annotation JoinTable add method:subClass() for List type field -Condition add method: -public Condition opOn(String field, Op Op, Object value); - -MapSuid(the Javabean corresponding to the table is not required): -add method update,count,paging select, add and adjust insert and insertAndReturnId. - -PreparedSqlLib support selectMapList method. -Read/Write multi-DataSource support different type DataSource. -Logger: two method support have parameter Throwable. -sql log support config the log level. -add class StreamUtil -enhance check field -use LinkedHashMap in List<Map> result for selectMapList(String sql). -Condition support condition.set("fieldName", null). -selectJson support config long to string -enhance autoGenBean ,support to generate SQL Json Script. -Add general search function support (simplify back-end complex query programming). -enhance multi-thread support. -custom the path of bee.properties. -Generate Javabean(GenBean) support type:JSON,TEXT. - -fix bug for ExecutableSql. -transfer the the field of 'order by'. -fix null bug in create() of ObjectCreatorFactory. -fix bug for max column number(excel in bee-ext). -fix bug about HoneyContext -fix bug about checkPackageByClass -fix bug about multi-thread safe in ConditionHelper. +**Support many Database**(MySQL,MariaDB,Oracle,H2,SQLite,PostgreSQL,SQL Server,Cassandra and so on) and easily extend. +**Good performance, close to the speed of JDBC; Small files:Bee V1.8 jar 217k**, **V1.9.5 jar,315k, V1.9.8 jar 310k**. + +* 1.The interface is simple and easy to use, **Suid (select,update,insert,delete)** object-oriented operation. +* 2.All Suid(select,update,insert,delete) operation use the same Bee interface,no longer need new dao interface. +* 3.Convention-over-configuration:Javabean can no annotation,no xml. +* 4.Automatic filter the null and empty field for default. +* 5.Select some fields easily. +* 6.Dynamic & random combination of query conditions,no need to prepare the interface in advance; new query requirements, no need to change the query interface. +* 7.Native SQL sort support,native paging support(do not need select all records before). +* 8.Support return the JSON format query results directly; Chain programming. +* 9.Support:transaction ,same connection,for update,batch insert,procedure. +* 10.more tables select oriented object support(has not the n+1 problem,one to one,one to many,many to one,many to many).sub-field type support Javabean or List. +* 11.L1 cache, simple in concept and powerful in function; L1 cache can also be fine tuned like the JVM; Support updatable long-term cache list and update configuration table without restart. Inherently resistant to cache penetration. L2 cache extension support; Redis L2 cache support. +* 12.Support java_db naming translation and support customize,default implement. +* 13.Many DB supports easy extension(MySQL,MariaDB,Oracle,H2,SQLite,PostgreSQL,SQL Server,Cassandra,etc. are directly available),In theory, can support all DB which support JDBC. +* 14.Add multi-DataSource support(Write/Read, only Split Database);support Jndi DataSource. +* 15.Support use many type database at the same time(eg: use Mysql,Oracle,SQL Server at the same). +* 16.Support distributed primary key(global unique id,Serial distributed unique id in one workid). +* 17.The same database sub table support, dynamic table name mapping support. +* 18.Support interceptor、multi-tenant,convert PreparedStatement parameter,custom TypeHandler and process the ResultSet. +* 19.Suid,SuidRich,PreparedSql,MapSuid,MoreTable support set the dataSource name. +* 20.MapSuid:opertate(suid) the database no need Javabean. +* 21.No third-party plug-in dependency; It can be used in zero configuration. +* 22.**Good performance, close to the speed of JDBC**; Small files:Bee V1.8 jar 217k, **V1.9.5 jar,315k, V1.9.8 jar 310k**. +**Assist function**: +* 23.Automatically generate the Javabean via DB table or view.Automatically create table via the Javabean,JavaWeb back-end code;Can print non placeholder executable SQL statements to facilitate debugging; support generate JSON format SQL scripts. +* 24.Support reading excel and importing data from Excel to DB easily. +* 25.Stream tool class streamutil. +* 26.The front and back ends of complex queries can be automatically parsed. +* 27.Annotation support:PrimaryKey,Datetime,Createtime,Updatetime;JustFetch,ReplaceInto(MySQL). +* 28.Extensible annotation: multi tenant, fuzzy processing of sensitive information, automatic setting of field values, dictionary conversion, dicti18n multilingual International Dictionary conversion, column name and field name mapping. + +## Newest Function + +**V1.11**(**International Labour Day**) +**Detail:** +V1.11.0.1.1(**2022 New Year**) +SuidRich add method: + public long insertAndReturnId(T entity,IncludeType includeType); +PreparedSql add method: + public List select(String sql,T returnType); +add annotation PrimaryKey +MapSqlKey support PrimaryKey +BF is shortcut for BeeFactoryHelper +Enhance:config info add trim() about multi-DataSource Write/Read +fix a bug for naming transfer + +V1.11.0.2.1(**2022 Spring Festival**) +add function: Interceptor、multi-tenant +add Interceptor,InterceptorChain +add DefaultInterceptor,CommInterceptorChain,DefaultInterceptorChain + +V1.11.0.2.4(**2022 Beijing Winter Olympics**) +level tow ext cache support +Redis cache support +add BeeExtCache,DefaultBeeExtCache +add BeeExtRedisCache + +V1.11.0.2.15(**2022 the Lantern Festival**) +add annotation:Datetime,Createtime,Updatetime;JustFetch +add support Jndi DataSource +check MapSqlKey value + +V1.11.0.2.20(**Honor**) +Optimize use different Database Type at same time(multi-Ds) +Support use differnt type Database at the same time(eg:use Mysql,Oracle,SQL Server at same time) +PreparedSql,MapSuid support Interceptor +Suid,PreparedSql,MapSuid support get DataSource,get InterceptorChain +Suid,PreparedSql,MapSuid,MoreTable add method:setDataSourceName,getDataSourceName,getInterceptorChain +add Annotation: +AnnotationHandler,AutoSetString +Desensitize +ReplaceInto,MySQL replace into +MultiTenancy +BeforeReturnAnnotationHandler,AbstractDictI18nDefaultHandler +Dict +DictI18n + +V1.11.0.2.28 (**Special Day**) +add ShardingStruct prepare for sharding. +add Column annotation support to extend mapping column and Javabean field name. +support custom TypeHandler,and process the ResultSet. +PreparedSql custom sql support more table select,and return more table struct Javabean. +fixed bug: +More table self association query of the same entity forbid multi-self-cycles + +V1.11.0.3.8 (**Lady First**) +add SetParaTypeConvert for convert PreparedStatement parameter. +Javabean use java.util.Date type for SUID compatibility processing. +SQLite get the timestamp result for conversion. +The Json field of DB is automatically converted to the attribute marked with Json annotation of Javabean(Javabean structure corresponding to Json). + +V1.11.0.3.12 (**Tree Planting Day**) +Ddl.java uses Javabean to create tables, supports the mapping between Java and DB field types, and supports the setting java_dbtype mapping. +Ddl.java is compatible with raw char type and java.util.Date. +PreparedSql support batch insert. +Support Suid instance set NameTranslate. +Add DbFeature Registry,it is easy for setting custom database dialect. +Support Cassandra. + +V1.11.0.3.20 (**Spring Equinox**) +add Custom dynamic SQL token,@in,@toIsNULL1,@toIsNULL2,<if isNotNull>,<if isNotBlank>. +dynamic SQL list transfer list to SQL in eg:in (1,2,3),no need foreach;batch insert also no need foreach. +Separate CN and EN API. + +V1.11.0.4.22 (**The World Earth Day**) +Add registry interface; Add nameregistry. +Change serializer throws exceptions type. +Mapsuid and mapsql support parsing string to boolean type. +Genbean, which does not support JDBC type, reminds you which file to set; +Genbean support config where override the old file; +Genbean support gen javabean's field file; +SuidRich's method selectString support variable-length arguments: + public List selectString(T entity,String... selectFields); +CommInterceptorChain check whether add same class. +SystemLogger supports setting log level to facilitate development and debugging. +The logger add method: public static void debug (string MSG, throwable T) (convenient for development and debugging). +Nocache add log prompt. +Improve cache security. +Add preload SPI interface Preload. +Add InterceptorChainRegistry, an interceptor registrar for global use. +Add configuration item: +pagingWithLimitOffset +notCatchModifyDuplicateException +notShowModifyDuplicateException +fixed bug for type converter. +fixed bug about @PrimaryKey in Suid update(entity). + +V1.11.0.4.29 +The configuration file supports multi-environment differentiated configuration. +SuidRich,public int update(T oldEntity, T newEntity) Interceptors only handle newEntity. ## [Function Detail](../../../bee/blob/master/Changed_Log.md) [click for: Function Detail](../../../bee/blob/master/Changed_Log.md) @@ -300,18 +293,18 @@ Quick Start: org.teasoft bee - 1.9.8 + 1.11 org.teasoft honey - 1.9.8 + 1.11 org.teasoft bee-ext - 1.9.8 + 1.11 ``` @@ -326,10 +319,11 @@ Create the tables and init the data by run the [init-data(user-orders)-mysql.sql ## 3. Update the database configuration in bee.properties if need If no the bee.properties file, you can create it by yourself. -//#bee.databaseName=MySQL +\#bee.databaseName=MySQL bee.db.dbName=MySQL bee.db.driverName = com.mysql.jdbc.Driver -bee.db.url =jdbc:mysql://localhost:3306/bee?characterEncoding=UTF-8 +\#bee.db.url =jdbc:mysql://localhost:3306/bee?characterEncoding=UTF-8 +bee.db.url =jdbc:mysql://127.0.0.1:3306/bee?characterEncoding=UTF-8&useSSL=false bee.db.username = root bee.db.password = @@ -402,6 +396,9 @@ public class SuidExamEN { #### [Bee+Spring-boot Demo](../../../bee-starter-demo/) +### Bee Architecture + + ### Bee Common Interface @@ -416,7 +413,50 @@ Rapid application development: [Bee + Spring Boot](../../../bee-springboot) ... - + +Other Document: +========= +### API-DOC +API-V1.9.8 SourceCode contain bee-1.9.8-javadoc.zip +API-V1.11(Newest) SourceCode contain bee-1.11 CN & EN API,bee-1.11 CN SourceCode + +[wiki Document](../../../bee/wikis) + +[CSDN: ORM Bee Document](https://blog.csdn.net/abckingaa/article/details/121664398) + +Enterprise Edition: +========= +In order to provide more and more powerful functions, Bee team cooperates with the enterprise to launch the Enterprise Version. +### New Features +We hope to provide more easy-to-use Bee functions to further improve the efficiency of development! +* 1.Reduce the difficulty of development financial computing projects, simplify financial digital calculation, etc +* 2.@AutoSetString annotation ease of use improvement, easy to handle automatic filling functions such as CreateBy,UpdateBy +Automatically insert values for tenants +* 3.@Desensitize, change some sensitive information to mask characters +* 4.@Dict specific field dictionary value conversion +* 5.@DictI18n multilingual International Dictionary conversion, global unified setting, no need to set one by one, saving time and effort +* 6.@MultiTenancy multi-tenant +* 7.@Column when Javabean attribute is inconsistent with the table column name, define the mapping relationship (not recommended for new system, mainly for compatibility with old system) +* 8.@Json Entity properties are Javabean and the JSON type column of DB table are converted automatically during parameter setting and query results +* 9.Support the automatic generation of EDI XML electronic message + +### Price +**Enterprise** users: +USD 199.00 +**Personal** users: +USD 49.00 + +### Technical Support +**The use of Enterprise Edition, professional technical support and solution consultation are provided by the following companies:** +**Shenzhen Caifeng software** +(Enterprises willing to join in, please contact us!) + +### Discount(2022) +Before June: 40% discount +Before July: 30% discount +Before August: 20% discount +Before October: 10% discount + Contact & Welcome: ========= #### Author's email: honeysoft@126.com diff --git a/README_CN.md b/README_CN.md index 52f20dd2458c4e07df7ab71bc44be7f5bb7030c0..50805641481cc3f5bba7c70710f08a6353accb75 100644 --- a/README_CN.md +++ b/README_CN.md @@ -1,10 +1,19 @@ Bee ========= +#### 好消息: +**2022年5月1日**(劳动节)前登记的企业用户,可获得专业的生产环境使用帮助,为你的系统保驾护航、提高性能; +个人用户登记后入群,可获得个性化的使用咨询! +登记地址: +https://gitee.com/automvc/bee/issues/I3PIUJ +https://github.com/automvc/bee/issues/43 + +完成**登记的伙伴**,请加QQ群(**992650213**),找群主领资料! + #### 工欲善其事必先利其器!——《论语·卫灵公》 #### 为适应互联网时代软件需求量大,需求变更频繁,性能要求高等要求,ORM Bee应运而生! -**Bee**,互联网新时代的Java ORM框架,更快、更简单、更自动,开发速度快,运行快,更智能! +**Bee**,互联网新时代的Java ORM框架,更快、更简单、更自动,开发速度快,运行快,更智能! **Bee**,一个简单,易用,功能强大(编码少、开发速度快,运行快)的 JAVA ORM 框架。 **Bee简单易用**:单表操作、多表关联操作,可以不用写sql,极少语句就可以完成SQL操作;**概念简单**,10分钟即可入门。 **Bee功能强大**:复杂查询也支持向对象方式,分页查询性能更高,一级缓存即可支持个性化优化;具有分布式特性。高级要求,还可以方便自定义SQL语句。运行速度接近直接用JDBC的速度。 @@ -41,80 +50,94 @@ Bee **简化了与DB交互的编码**工作量.连接,事务都可以由Bee框 * 7.支持原生SQL排序, **原生语句分页**(不需要将全部数据查出来)。 * 8.支持**直接返回Json**格式查询结果; 链式编程。 * 9.支持**事务**、多个ORM操作使用同一连接、**for update**,支持**批处理**操作,支持原生SQL(**自定义sql**语句),支持**存储过程**。 -* 10.支持面向对象方式复杂查询、**多表查询**(无n+1问题; 支持:一对一,一对多,多对一,多对多)。 -* 11.**一级缓存**,概念简单,功能强大;一级缓存也可以**像JVM一样进行细粒度调优**;**支持可更新的长久缓存列表**,更新配置表,**不需要重启**。 +* 10.支持面向对象方式复杂查询、**多表查询**(无n+1问题; 支持:一对一,一对多,多对一,多对多;返回结果根据子表是否使用List有两种呈现结构)。 +* 11.**一级缓存**,概念简单,功能强大;一级缓存也可以**像JVM一样进行细粒度调优**;**支持可更新的长久缓存列表**,更新配置表,**不需要重启**。天生抵御缓存穿透 。 + **二级缓存扩展支持;内置Redis二级缓存支持**。 * 12.表名与实体名、字段名与属性名映射默认提供多种实现,且支持**自定义映射规则扩展**。 -* 13.**多种DB**支持轻松扩展(MySQL,MariaDB,Oracle,H2,SQLite,PostgreSQL,SQL Server等直接可用)。 -* 14.支持**读写分离**一主多从, 仅**分库**等**多数据源**模式(对以前的代码无需修改,该功能对代码是透明的,即无需额外编码),**可同时使用多种类型数据库**。 -* 15.**分布式**环境下生成**连续单调递增**(在一个workerid内),**全局唯一**数字**id**;提供自然简单的分布式主键生成方式。 -* 16.**支持同库分表,动态表名映射**。 -* 17.可以不用表对应的Javabean也能操作DB。 -* 18.**无**第三方插件依赖;可零配置使用。 -* 19.**性能好:接近JDBC的速度;文件小:Bee V1.8 仅217k**, **V1.9.5 仅315k,V1.9.8 仅310k**。 -辅助功能: -* 20.支持自动生成表对应的Javabean,根据Javabean创建表,Javaweb**后端代码**根据**模板自动生成**;能打印非占位符的**可执行sql**,方便调试。 -* 21.支持**读取Excel**,从Excel导入数据到DB,操作简单。 +* 13.**多种DB**支持轻松扩展(MySQL,MariaDB,Oracle,H2,SQLite,PostgreSQL,SQL Server,**Cassandra**等直接可用),理论上支持JDBC的DB都可以支持。 +* 14.支持**读写分离**一主多从, 仅**分库**等**多数据源**模式(对以前的代码无需修改,该功能对代码是透明的,即无需额外编码);Jndi数据源支持。 +* 15.**支持同时使用多种数据库(如同时使用Mysql,Oracle,SQL Server)**。 +* 16.提供自然简单的分布式主键生成方案:**分布式**环境下生成**连续单调递增**(在一个workerid内),**全局唯一**数字**id**。 +* 17.**支持同库分表,动态表名映射**。 +* 18.**拦截器、多租户,支持自定义TypeHandler,处理查询的ResultSet结果**。 +* 19.**Suid,SuidRich,PreparedSql,MapSuid,MoreTable支持设置数据源名称**。 +* 20.可以不用表对应的Javabean也能操作DB。 +* 21.**无**第三方插件依赖;可零配置使用。 +* 22.**性能好:接近JDBC的速度;文件小:Bee V1.8 仅217k**, **V1.9.5 仅315k,V1.9.8 仅310k**。 +**辅助功能**: +* 23.支持自动生成表对应的Javabean,根据Javabean创建表,Javaweb**后端代码**根据**模板自动生成**;能打印非占位符的**可执行sql**,方便调试;支持生成Json格式的SQL脚本。 +* 24.支持**读取Excel**,从Excel导入数据到DB,操作简单;支持从Excel获取配置生成数据库表。 +* 25.流的工具类StreamUtil。 +* 26.复杂查询前后端可自动解析。 +* 27.注解支持:PrimaryKey,Datetime,Createtime,Updatetime;JustFetch,ReplaceInto(MySQL)。 +* 28.可扩展注解:多租户,敏感信息模糊处理,自动设置字段值,Dict字典转化,DictI18n多语言国际化字典转化,Column列名与属性名映射。 +* 29.使用实体名_F引用实体字段名。 ## 最新功能介绍: -**V1.9** -(只是一部分) -多表关联查询支持多个关联条件. -多个ORM操作使用同一个Connection. -支持同时使用不同数据库(多个数据源). -支持长度大于0空字符串忽略处理,如"     ". -增加Ignore注解,忽略Javabean字段,不进行转换. -用模板生成文件支持自定义起止标签. -加强代码质量(测试覆盖率达70%以上,关键代码达90%以上). -增强链式编程:Select,Update. -整合Spring boot,提供bee-spring-boot-starter. -支持利用Javabean生成表. -修复多表分页查询时,同名字段在部分数据库会混淆的缺陷(oracle). -修复缺陷:update默认主键为id时,无id字段或id为null时,异常处理. -修复缺陷:jdk 11下,LoggerFactory在配置log4j2时,报错. - -**V1.9.8**(2021中秋节) -SuidRich增加4个方法: -public int save(T entity); -public int update(T oldEntity,T newEntity); -public String selectJson(T entity, String selectField); -public String selectJson(T entity, String selectField, int start, int size); - -MoreTable(多表查询): -支持子表实体字段为List类型的多表关联查询. -支持两个子表的join关联查询(inner join,right join, left join); -支持一个子表里还有一个子表的关联查询. -修复问题:当一个子表的属性都为null时,子表字段直接设置为null. -注解 JoinTable添加方法:subClass()用于List类型字段的多表关联查询. -Condition新增方法,用于在关联查询时的on表达式达到提前过滤数据: -public Condition opOn(String field, Op Op, Object value); - -MapSuid(不用Javabean实体结构操作数据库): -新增update,count,查询分页,新增和调整insert and insertAndReturnId. -至此,MapSuid的select,update,insert,delete及分页功能已完备. - -PreparedSqlLib新增selectMapList方法. -多数据源读写模式,支持不同类型数据源,方便数据库间转移数据. -Logger: 两个方法支持有Throwable参数. -sql输出日志支持logger不同级别输出设置. -增加流的工具类StreamUtil. -增强检测字段合法性,包括MapSuid使用的字段. -use LinkedHashMap in List<Map> result for selectMapList(String sql). -Condition支持condition.set("fieldName", null). -selectJson支持通过配置将long转为string. -增强autoGenBean ,支持生成Json格式的SQL脚本(SQL Json Script). -添加通用查询功能支持(简化后端复杂查询编程). -增强多线程支持. -可指定bee.properties所在路径. -自动生成Javabean(GenBean)支持类型:JSON,TEXT. - -fix bug for ExecutableSql. -transfer the the field of 'order by'. -fix null bug in create() of ObjectCreatorFactory. -fix bug for max column number(excel in bee-ext). -fix bug about HoneyContext. -fix bug about checkPackageByClass. -fix bug about multi-thread safe in ConditionHelper. +V1.11 (**International Labour Day**) +1)拦截器、多租户 +2)增加ShardingStruct为分库分表作准备 +3)二级缓存扩展支持 +Redis缓存支持 +3)支持自定义TypeHandler,处理查询的ResultSet结果 +4)add SetParaTypeConvert for convert PreparedStatement parameter +5)支持在Suid等对象设置命名转换器. +增加DbFeature方言注册器,自定义实现不同DB方言更加易用. +6)支持Cassandra. +7)添加Jndi数据源支持 +8)Ddl.java使用Javabean创建表,支持追加java与db字段类型映射,支持设置某个DB的java_dbtype类型映射. +9)PreparedSql自定义sql支持批量插入. +PreparedSql自定义sql支持多表查询,返回多表关联Javabean结构数据 +10)自定义动态SQL标签,@in,@toIsNULL1,@toIsNULL2,,. +动态sql,将list转为像in (1,2,3)的语句,不需要foreach,批量插入也不需要foreach. +11)注册器: +CalculateRegistry,计算分版算法注册器 +DbFeatureRegistry,DB方言特性注册器 +InterceptorChainRegistry,拦截器链注册器 +NameRegistry,命名转换注册器 +SetParaTypeConverterRegistry, PreparedStatement参数类型转换注册器 +TypeHandlerRegistry 查询结果转换注册器 +12)配置文件支持多环境差异化配置. + +添加注解: +PrimaryKey,Datetime,Createtime,Updatetime;JustFetch +AnnotationHandler,AutoSetString自动设置字符值 +Desensitize,敏感信息模糊处理 +ReplaceInto,MySQL replace into转换 +MultiTenancy多租户 +BeforeReturnAnnotationHandler,AbstractDictI18nDefaultHandler +Dict字典转化 +DictI18n多语言国际化字典转化 +Column列名与属性名映射扩展支持 + +增强: +multi-DS同时使用不同类型DB优化 + (比如,同时使用Mysql,Oracle,SQL Server) +可用BF代替BeeFactoryHelper加快输入 +Javabean使用java.util.Date类型,进行SUID作兼容处理. +Ddl.java兼容原生char类型,兼容java.util.Date. +SQLite获取Timestamp结果作转化处理. +实体属性是Javabean与DB表Json类型字段在参数设置与查询结果时自动转换(使用Json注解自定义实现). +读写模式配置信息去除空格 +检测MapSqlKey的值 +增加Registry空接口;增加NameRegistry. +更改Serializer接口抛出异常方式. +MapSuid,MapSql支持解析字符串的Boolean类型. +GenBean,还不支持的jdbc类型,提醒在哪个文件设置. +GenBean增加支持是否覆盖原有文件设置. +GenBean增加获取字段支持,使用字段名可以不直接使用字符串. +SuidRich的selectString方法支持可变参数: +public List selectString(T entity,String... selectFields); +CommInterceptorChain增加检测是否添加了相同类型拦截器. +提高缓存安全. +添加SPI预加载接口PreLoad. +添加用于全局的拦截器注册器InterceptorChainRegistry. +SuidRich,public int update(T oldEntity, T newEntity)拦截器只处理新实体newEntity. + +fixed bug: +naming transfer +多表查询同一个实体自我关联查询禁止自我多次循环 ## [详细完整功能介绍](../../../bee/blob/master/Changed_Log_CN.md) [点击链接可查看 详细完整功能介绍](../../../bee/blob/master/Changed_Log_CN.md) @@ -260,18 +283,18 @@ OrdersService.java org.teasoft bee - 1.9.8 + 1.11 org.teasoft honey - 1.9.8 + 1.11 org.teasoft bee-ext - 1.9.8 + 1.11 ``` @@ -285,18 +308,20 @@ OrdersService.java ## 3. 更新数据库的配置信息(在bee.properties) 注:如果还没有bee.properties文件,可以自己新建一个. +(默认的bee.properties位于Hoeny工程下,对应HoneyConfig.java,列举了Bee所有会用到的配置) 也可以配置数据源(此处只是一个例子). -//#bee.databaseName=MySQL +\#bee.databaseName=MySQL bee.db.dbName=MySQL bee.db.driverName = com.mysql.jdbc.Driver -bee.db.url =jdbc:mysql://localhost:3306/bee?characterEncoding=UTF-8 +\#bee.db.url =jdbc:mysql://localhost:3306/bee?characterEncoding=UTF-8 +bee.db.url =jdbc:mysql://127.0.0.1:3306/bee?characterEncoding=UTF-8&useSSL=false bee.db.username = root bee.db.password = ## 4. 生成Javabean Orders可参考: [Orders(Javabean)](../../../bee-exam/blob/master/src/main/java/org/teasoft/exam/bee/osql/entity/Orders.java) -[Auto Genernate Javabean](../../../bee-exam/blob/master/src/main/java/org/teasoft/exam/bee/osql/autogen/GenBeanExam.java) +[自动生成Javabean](../../../bee-exam/blob/master/src/main/java/org/teasoft/exam/bee/osql/autogen/GenBeanExam.java) ## 5. 运行下面的 java代码 @@ -366,13 +391,8 @@ public class SuidExam { #### [Bee+Spring-boot Demo](../../../bee-starter-demo/) -### API-DOC -[API-V1.9.5](https://gitee.com/automvc/bee/attach_files/692020/download) - -API-V1.9.8(最新版) 下载代码含有 bee-1.9.8-javadoc.zip - ### Bee架构介绍 - + ### Bee常用接口介绍 @@ -394,6 +414,50 @@ API-V1.9.8(最新版) 下载代码含有 bee-1.9.8-javadoc.zip ## [FAQ常见问题](../../../bee/blob/master/FAQ_CN.md) [点击链接可查看 FAQ常见问题](../../../bee/blob/master/FAQ_CN.md) + +其它学习资料: +========= +### API-DOC +API-V1.9.8 下载代码含有 bee-1.9.8-javadoc.zip +API-V1.11(最新版) 下载代码含有 bee-1.11中文和英文版API,bee-1.11中文版源码 + +### 使用文档 +[wiki 文档](../../../bee/wikis) + +[CSDN: ORM Bee资料大全](https://blog.csdn.net/abckingaa/article/details/121664398) + +企业版: +========= +为了给大家提供更多更强大的功能,Bee团队与企业合作,推出企业版本. +### 新增特性 +**我们希望提供更多简单易用的Bee功能!进一步提高开发效率! ** +* 1.降低金融计算型项目开发难度,简化金融数字计算等 +* 2.@AutoSetString注解易用性改进,轻松处理像CreateBy,UpdateBy等自动填充功能 +* 自动插入租户的值 +* 3.@Desensitize,敏感信息模糊处理 +* 4.@Dict具体字段字典数值转化 +* 5.@DictI18n多语言国际化字典转化,全局统一设置,无需逐个设置,省时省力 +* 6.@MultiTenancy多租户 +* 7.@Column实现Javabean属性与表列名不一致时,定义映射关系(新系统不建议使用,主要是为了兼容旧系统) +* 8.@Json实体属性是Javabean与DB表Json类型字段在参数设置与查询结果时自动转换 +* 9.支持EDI XML电子报文自动生成 + +### 价格 +**企业**用户: +¥999 +**个人**用户: +¥198 +### 优惠(2022) +五一期间(5.1-5.4) **5折** +六一之前**6折** +七一之前**7折** +八一之前**8折** +国庆之前**9折** + +### 技术支持 +**企业版使用,专业技术支持,解决方案咨询,由以下单位提供:** +**深圳彩凤软件** +(有意愿加入的企业,请联系我们!) 联系与欢迎: ========= diff --git a/bee-1.11-CN-javadoc.zip b/bee-1.11-CN-javadoc.zip new file mode 100644 index 0000000000000000000000000000000000000000..fabdc931410b5eac61b4ebd6c0a1a3969a129616 Binary files /dev/null and b/bee-1.11-CN-javadoc.zip differ diff --git a/bee-1.11-CN-sources.jar b/bee-1.11-CN-sources.jar new file mode 100644 index 0000000000000000000000000000000000000000..be978286acd824c9fc7210e20ccff0c2d5c81811 Binary files /dev/null and b/bee-1.11-CN-sources.jar differ diff --git a/bee-1.11-javadoc.zip b/bee-1.11-javadoc.zip new file mode 100644 index 0000000000000000000000000000000000000000..dcee1310432ea4663954ee29d73a0a997605f17c Binary files /dev/null and b/bee-1.11-javadoc.zip differ diff --git a/pom.xml b/pom.xml index fc340a7aa659ee923a1a18e5c8025acff39bb338..4625917ccf055760662a4303edf37ff878670efd 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.teasoft bee - 1.9.8 + 1.11 jar @@ -20,7 +20,7 @@ 3.0.0 - + org.apache.maven.plugins maven-source-plugin @@ -34,6 +34,28 @@ + + + diff --git a/src/main/java/org/teasoft/bee/distribution/GenId.java b/src/main/java/org/teasoft/bee/distribution/GenId.java index 4210a7072ff795b1d22197e10807e317bbd58e9c..6bffe91ef54a9e5f5b7017f69e364c07f63207d3 100644 --- a/src/main/java/org/teasoft/bee/distribution/GenId.java +++ b/src/main/java/org/teasoft/bee/distribution/GenId.java @@ -19,110 +19,43 @@ package org.teasoft.bee.distribution; /** * - * 分布式环境下生成全局唯一数字id.Generate global unique id number in distributed environment. + * Generate global unique id number in distributed environment. * GUID : Global Unique ID. * - * 分段模式与雪花到底有什么区别? - * 一个是依赖DB,一个是依赖时间的. - * 一个是取的号码可以一直连续递增的;一个是趋势递增,会因workerid的原因产生的ID号是会跳很大一段的. - * 依赖于DB的号段模式,当多个节点一起拿号时,最终落库的ID还是不能连续的。 - * 雪花ID适合做分布式数据库表主键吗?它只保证递增,没保证连续。 - * - * 改进目标: - * 能不能找到一种,既不依赖DB,也不依赖时间的ID生成算法呢?答案是,肯定有的,这是我们努力的方向! - *

---------------------------------------------

org.teasoft.honey.distribution.PearFlowerId -

改进的雪花算法——姑且称为梨花算法(PearFlowerId)吧 (忽如一夜春风来,千树万树梨花开)。 -

改进目标:解决雪花算法的时钟回拨问题;部分避免机器id重复时,号码冲突问题。 - -

long型的64位分成以下几个部分组成: -

符号位:1位 -

时间:31位 (精确到秒)够用68年 -

段号(批次号):3位 每秒可分为8个段 -

机器号:10位 最多支持1024台机器 -

序列号:19位 可表示:0--524287 - -

注:根据情况,机器号可以调整到最后部分。 -

每个机器,每秒可生成4.19w个id(4194304). - -

经过调整,时间只对秒灵敏,成功回避了服务器间几百毫秒的时间误差引起的时间回拨问题;若第59秒的8个段号没有用完, -

则当润秒来临时,还可继续使用。另外具体实现上,可设置一定的秒数(如3秒)内提前消费。比如第10秒的号码,在800毫 -

秒用完了,可以继续使用第11秒的号码。这样,下1秒用的号码不是很多时,就可以借给上1秒使用。 -

以上的方案是与时间强相关的。若某一段时间内的号码没用使用,也会浪费掉。当在分布式DB的表主键这种应用场景时, -

只需要全局id不重复,且是递增的。类似这种场景,可以设计成时间不相关的。 -

供分布式DB表主键等类似场景使用,不浪费号码的方案。long型的64位分配还是一样。只不过,取号时,是取上一个号码加1, -

而不用管现在的时间是什么时候。当突然down机时,重启又获取当前的时间,重新开始分派号码;这时之前节省下的号码就被浪 -

费掉了。为解决这个问题,可以在一段时间或分派一定数量的号(如10000),就将当前分派的号码记录到日志,或同步到DB表, -

等重启时,可以设置初始值。实现上,还是要控制分派的速度,若每秒几百万的号不够用,可用表名分隔命名空间,每个表单独取 -

自己的号;即使号码够用,也可以这样做,因为这样得到的号在同一张表里就比较连续,而不只是递增而矣。当各个机器分派的id -

速度相差太大时,各机器得到的id大小就比较乱;这种问题,可以设置负载均衡,让每台机器轮流出号。 - -

机器id重复的问题。当两台机器的id一样时,分派的号就会重复。若0-7八个段号(段号3位),每次都是从0-3随机获取一个 -

开始的段号,比方说获取到2,那重复机器id的服务要是获取到0或1的段号就可以避免号码重复的冲突。当然了,这都是基于每秒用 -

不完号码的情况下的。可以循环使用段号,如获取到3,那就从3-7,0,1,2这样使用段号,后面0,1,2这几个段号要是分派出去, -

号码就不递增了。具体怎么用,还是要根据自己的情况做取舍。

---------------------------------------------

org.teasoft.honey.distribution.SerialUniqueId - * 在一个workerid内连续唯一的ID生成方法(绝对连续单调递增,全局唯一).Serial Unique Id in one workerid. - * 优点:连续唯一;不依赖时钟. 在DB内实现,可达到分布式全局唯一ID在DB内自增长;在同一个workerid内,获取的ID号,可以满足连续单调递增唯一. + * Serial Unique Id in one workerid. * Advantages:continuous and unique;less clock dependent.Implemented in dB, it can achieve auto increment * of distributed global unique ID in dB. The ID number get in the same workerid can satisfy continuous * monotonic increasing uniqueness. - * 缺点/Shortcoming:worker1's ID ---------------------------------------------

org.teasoft.honey.distribution.OneTimeSnowflakeId - * OneTimeSnowflakeId,进一步改进了梨花算法。 - * 不依赖时间的梨花算法,Workerid应放在序号sequence的上一段,且应用SerialUniqueId算法,使ID不依赖于时间自动递增。 - * 使用不依赖时间的梨花算法OneTimeSnowflakeId,应保证各节点大概均衡轮流出号,这样入库的ID会比较有序,因此每个段号内的序列号不能太多。 - * 支持批获取ID号。可以一次取一批ID(即一个范围内的ID一次就可以获取了)。可以代替依赖DB的号段模式。 - * 应用订单号等有安全要求的场景,可随机不定时获取一些批的号码不用即可。 - * 考虑到2019年双11的峰值不超过55万笔/秒, 因此419w/s这个值已可以满足此苛刻要求;采用testSpeedLimit()检测平均值不超过419w/s这个值即可,而且在空闲时 - * 段省下的ID号,还可以在高峰时使用。 - * + * @author Kingstar * @since 1.7.2 */ public interface GenId { /** - * 返回id号码.return the id number. - * @return long id号码.long id number. + * return the id number. + * @return long id number. */ public long get(); /** - * 一次获取一段号码,返回一个批次可用号码的最小值和最大值,eg: [100000,101000].return the min and max long in this batch.eg: [100000,101000] - *
在一些算法中,如:PearFlowerId,OneTimeSnowflakeId, - *
1) 参数sizeOfIds不应该大于8192. - *
2) 为了使array[0]=min,array[1]=max在连续的范围,会存在浪费id号的可能; - *
如果不想出现这种情况,可以循环调用get()方法,或使用SerialUniqueId算法. - *
SerialUniqueId算法不会出现以上两种问题. + * Get a segment of numbers at a time and return the minimum and maximum available numbers of a batch. + *
eg: [100000,101000],array[0]=100000,array[1]=101000. *
In some algorithms, such as:PearFlowerId,OneTimeSnowflakeId, *
1) The parameter sizeOfIds should not be greater than 8192. *
2) In order to make array[0]=min,array[1]=max in the range of series, it is possible to waste id number; *
if you don't want to, you can loop call the get() method or use SerialUniqueId algorithm. *
The SerialUniqueId algorithm does not have the above two problems. - * @param sizeOfIds 返回的一批id的数量.the size Of ids in one batch. + * @param sizeOfIds the size Of ids in one batch. * @return return the array of long. array[0]=min,array[1]=max. */ public long[] getRangeId(int sizeOfIds); diff --git a/src/main/java/org/teasoft/bee/distribution/Worker.java b/src/main/java/org/teasoft/bee/distribution/Worker.java index df488e4725c1671f9fd79d79a680ab41a7bef769..1ce8e93e69dc121b2c808a98ff94e436160531c6 100644 --- a/src/main/java/org/teasoft/bee/distribution/Worker.java +++ b/src/main/java/org/teasoft/bee/distribution/Worker.java @@ -18,14 +18,14 @@ package org.teasoft.bee.distribution; /** - * 用于唯一标识在一个运行的ID生成程序.uniquely identify the ID generator running in an application. + * uniquely identify the ID generator running in an application. * @author Kingstar * @since 1.7.2 */ public interface Worker { /** - * 获取唯一标识ID生成程序的ID编号.get long number of unique worker ID. + * get long number of unique worker ID. * @return long number of unique worker ID. */ long getWorkerId(); diff --git a/src/main/java/org/teasoft/bee/distribution/ds/Route.java b/src/main/java/org/teasoft/bee/distribution/ds/Route.java index 1990fac4dec3cb5c588e7394f61a8298c3cb4ed1..86a00196aa8fd547cc9d667a2792b5c10ab77fde 100644 --- a/src/main/java/org/teasoft/bee/distribution/ds/Route.java +++ b/src/main/java/org/teasoft/bee/distribution/ds/Route.java @@ -18,14 +18,14 @@ package org.teasoft.bee.distribution.ds; /** - * 多数据源的路由接口.the route interface of multi-DataSource. + * the route interface of multi-DataSource. * @author Kingstar * @since 1.8 */ public interface Route { /** - * 返回数据源的名称.Return the name of DataSource. + * Return the name of DataSource. * @return the name of DataSource. */ public String getDsName(); diff --git a/src/main/java/org/teasoft/bee/distribution/sharding/DsTabStruct.java b/src/main/java/org/teasoft/bee/distribution/sharding/DsTabStruct.java new file mode 100644 index 0000000000000000000000000000000000000000..cfab7bb4a31ad757c2ae52695e8c034c1e7159ad --- /dev/null +++ b/src/main/java/org/teasoft/bee/distribution/sharding/DsTabStruct.java @@ -0,0 +1,91 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.distribution.sharding; + +/** + * DataSource and Table Struct + * @author Kingstar + * @since 1.11 + */ +public class DsTabStruct { + + /** + * dataSource name + */ + private String dsName; + + /** + * table name + */ + private String tabName; + + /** + * table name Suffix + * can set when tabName use Entity name transfer + */ + private String tabSuffix; + + /** + * get dataSource name + * @return dataSource name + */ + public String getDsName() { + return dsName; + } + + /** + * set dataSource name + * @param dsName dataSource name + */ + public void setDsName(String dsName) { + this.dsName = dsName; + } + + /** + * get table name + * @return table name + */ + public String getTabName() { + return tabName; + } + + /** + * set table name + * @param tabName table name + */ + public void setTabName(String tabName) { + this.tabName = tabName; + } + + /** + * return table name suffix + * @return table name suffix + */ + public String getTabSuffix() { + return tabSuffix; + } + + /** + * set table name suffix + * can set when tabName use Entity name transfer + */ + public void setTabSuffix(String tabSuffix) { + this.tabSuffix = tabSuffix; + } + +} diff --git a/src/main/java/org/teasoft/bee/distribution/sharding/ShardingStruct.java b/src/main/java/org/teasoft/bee/distribution/sharding/ShardingStruct.java new file mode 100644 index 0000000000000000000000000000000000000000..9e05a2f9d1e4e93a7e733e2cb24e4bab7d0c45a9 --- /dev/null +++ b/src/main/java/org/teasoft/bee/distribution/sharding/ShardingStruct.java @@ -0,0 +1,148 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.distribution.sharding; + +/** + * ShardingStruct + * @author Kingstar + * @since 1.11 + */ +public class ShardingStruct { + + private int dsAlgorithm; + private String dsRule; + private String dsName; + private int tabAlgorithm; + private String tabRule; + private String tabName; + + private Object shardingValue; + + /** + * get dataSource algorithm + * @return dataSource algorithm + */ + public int getDsAlgorithm() { + return dsAlgorithm; + } + + /** + * set dataSource algorithm + * @param dsAlgorithm dataSource algorithm + */ + public void setDsAlgorithm(int dsAlgorithm) { + this.dsAlgorithm = dsAlgorithm; + } + + /** + * get dataSource rule + * @return dataSource rule + */ + public String getDsRule() { + return dsRule; + } + + /** + * set dataSource rule + * @param dsRule dataSource rule + */ + public void setDsRule(String dsRule) { + this.dsRule = dsRule; + } + + /** + * get dataSource name + * @return dataSource name + */ + public String getDsName() { + return dsName; + } + + /** + * set dataSource name + * @param dsName + */ + public void setDsName(String dsName) { + this.dsName = dsName; + } + + /** + * get table algorithm + * @return table algorithm + */ + public int getTabAlgorithm() { + return tabAlgorithm; + } + + /** + * set table algorithm + * @param tabAlgorithm table algorithm + */ + public void setTabAlgorithm(int tabAlgorithm) { + this.tabAlgorithm = tabAlgorithm; + } + + /** + * get table rule + * @return table rule + */ + public String getTabRule() { + return tabRule; + } + + /** + * set table rule + * @param tabRule table rule + */ + public void setTabRule(String tabRule) { + this.tabRule = tabRule; + } + + /** + * get table name + * @return table name + */ + public String getTabName() { + return tabName; + } + + /** + * set table name + * @param tabName + */ + public void setTabName(String tabName) { + this.tabName = tabName; + } + + /** + * get sharding value + * @return sharding value + */ + public Object getShardingValue() { + return shardingValue; + } + + /** + * set sharding value + * @param shardingValue sharding value + */ + public void setShardingValue(Object shardingValue) { + this.shardingValue = shardingValue; + } + +} diff --git a/src/main/java/org/teasoft/bee/distribution/sharding/algorithm/Calculate.java b/src/main/java/org/teasoft/bee/distribution/sharding/algorithm/Calculate.java new file mode 100644 index 0000000000000000000000000000000000000000..80f625d0a2d37d607063fdc6e4d6c10f6bbb6d77 --- /dev/null +++ b/src/main/java/org/teasoft/bee/distribution/sharding/algorithm/Calculate.java @@ -0,0 +1,34 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.distribution.sharding.algorithm; + +/** + * sharding algorithm Calculate interface. + * @author Kingstar + * @since 1.11 + */ +public interface Calculate { + + /** + * return the value after process. + * @param rule rule + * @param shardingValue sharding value + * @return the value after process. + */ + String process(String rule, String shardingValue); +} diff --git a/src/main/java/org/teasoft/bee/distribution/sharding/algorithm/CalculateRegistry.java b/src/main/java/org/teasoft/bee/distribution/sharding/algorithm/CalculateRegistry.java new file mode 100644 index 0000000000000000000000000000000000000000..973783188dc573d339f6cac6138814a5f9c59c2e --- /dev/null +++ b/src/main/java/org/teasoft/bee/distribution/sharding/algorithm/CalculateRegistry.java @@ -0,0 +1,41 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * The license,see the LICENSE file. + */ + +package org.teasoft.bee.distribution.sharding.algorithm; + +import java.util.HashMap; +import java.util.Map; + +import org.teasoft.bee.osql.Registry; + +/** + * Calculate Registry + * @author Kingstar + * @since 1.11 + */ +public class CalculateRegistry implements Registry { + + private static final Map calculateMap = new HashMap<>(); + + /** + * register Calculate. + * @param type number type + * @param calculate instance of Calculate type + */ + public static void register(int type, Calculate calculate) { + calculateMap.put(type + "", calculate); + } + + /** + * get Calculate. + * @param type number type + * @return instance of Calculate type + */ + public static Calculate getCalculate(int type) { + return calculateMap.get(type + ""); + } + +} diff --git a/src/main/java/org/teasoft/bee/file/FileCreator.java b/src/main/java/org/teasoft/bee/file/FileCreator.java index fe39cfd8a17a8453b52d3ba916b28cfab7711860..7520bcd0c6699231f214f29b42f15205fffa9857 100644 --- a/src/main/java/org/teasoft/bee/file/FileCreator.java +++ b/src/main/java/org/teasoft/bee/file/FileCreator.java @@ -18,47 +18,47 @@ package org.teasoft.bee.file; /** - * 文件创建接口.File creator interface. + * File creator interface. * @author Kingstar * @since 1.7.1 */ public interface FileCreator extends FileReader{ /** - * 将内容写到生成的文件中 - * @param fullPathAndName 全部路径,包括文件名 - * @param content 文件内容.content + * Write content to generated file. + * @param fullPathAndName All paths, including file names + * @param content file of content */ public void genFile(String fullPathAndName, String content); /** - * 将内容写到生成的文件中 - * @param fullPath 全部路径.full path - * @param fileName 文件名.file name - * @param content 文件内容.content + * Write content to generated file. + * @param fullPath full path + * @param fileName file name + * @param content file of content */ public void genFile(String fullPath, String fileName, String content); /** - * 将内容写到生成的文件中 - * @param basePath 基础路径. base path - * @param packagePath 包路径.package path - * @param fileName 文件名.file name - * @param content 文件内容.content + * Write content to generated file. + * @param basePath base path + * @param packagePath package path + * @param fileName file name + * @param content file of content */ public void genFile(String basePath,String packagePath, String fileName, String content); /** - * 将内容追加到文件尾部 - * @param fullPathAndName 全部路径,包括文件名 - * @param content 文件内容.content of file. + * Append content to the end of the file. + * @param fullPathAndName All paths, including file names + * @param content file of content * @since 1.7.2 */ public void genAppendFile(String fullPathAndName, String content); /** * set charsetName - * @param charsetName + * @param charsetName charset name * @since 1.8.9 */ public void setCharsetName(String charsetName); diff --git a/src/main/java/org/teasoft/bee/file/FileReader.java b/src/main/java/org/teasoft/bee/file/FileReader.java index 919b8d712234b5e2e84334cfd1439e1c57ea76f9..1bea491ffe4bc04337a684f78fce1e2c9e07a999 100644 --- a/src/main/java/org/teasoft/bee/file/FileReader.java +++ b/src/main/java/org/teasoft/bee/file/FileReader.java @@ -18,16 +18,27 @@ package org.teasoft.bee.file; import java.io.BufferedReader; +import java.io.File; /** - * 用来读取字符文件的便捷类.Easy class of Read file by fullPathAndName. + * Easy class of Read file by fullPathAndName. * @author Kingstar * @since 1.7.2 */ public interface FileReader { + /** - * 根据路径读取文件.read the file by fullPathAndName. - * @param fullPathAndName 全部路径,包括文件名 + * read the file by fullPathAndName. + * @param fullPathAndName All paths, including file names + * @return instance of BufferedReader */ public BufferedReader readFile(String fullPathAndName); + + /** + * read the file. + * @param file + * @return instance of BufferedReader + * @since 1.11 + */ + public BufferedReader readFile(File file); } diff --git a/src/main/java/org/teasoft/bee/logging/Log.java b/src/main/java/org/teasoft/bee/logging/Log.java index 014a64d6bb64bc6b2e74ec35bf0ed00e7daed811..20e1c61c27f94d2881823da6a075e6935b82164d 100644 --- a/src/main/java/org/teasoft/bee/logging/Log.java +++ b/src/main/java/org/teasoft/bee/logging/Log.java @@ -18,7 +18,7 @@ package org.teasoft.bee.logging; /** - * 日志接口.Log interface. + * Log interface. * @author Kingstar * @since 1.4 */ @@ -27,7 +27,7 @@ public interface Log { public boolean isTraceEnabled(); /** - * 记录一个跟踪级别的消息.Log a message at the TRACE level. + * Log a message at the TRACE level. * * @param msg the message string to be logged */ @@ -36,7 +36,7 @@ public interface Log { public boolean isDebugEnabled(); /** - * 记录一个调试级别的消息.Log a message at the DEBUG level. + * Log a message at the DEBUG level. * * @param msg the message string to be logged */ @@ -46,7 +46,7 @@ public interface Log { public boolean isInfoEnabled(); /** - * 记录一个信息级别的消息.Log a at the INFO level. + * Log a at the INFO level. * * @param msg the message string to be logged */ @@ -55,7 +55,7 @@ public interface Log { public boolean isWarnEnabled(); /** - * 记录一个警告级别的消息.Log a message at the level. + * Log a message at the level. * * @param msg the message string to be logged */ @@ -65,7 +65,7 @@ public interface Log { public boolean isErrorEnabled(); /** - * 记录一个错误级别的消息.Log a message at the ERROR level. + * Log a message at the ERROR level. * * @param msg the message string to be logged */ diff --git a/src/main/java/org/teasoft/bee/logging/Path.java b/src/main/java/org/teasoft/bee/logging/Path.java index 10240b950f36ed19886d6e8d0269abc0d33840ec..9d304b700707e603031a0d741bee46a0a4a13b97 100644 --- a/src/main/java/org/teasoft/bee/logging/Path.java +++ b/src/main/java/org/teasoft/bee/logging/Path.java @@ -18,7 +18,7 @@ package org.teasoft.bee.logging; /** - * 设置日志文件的路径与文件名.set the log file path(include file name). + * Set the log file path(include file name). * @author Kingstar * @since 1.7.2 */ diff --git a/src/main/java/org/teasoft/bee/osql/BeeAbstractFactory.java b/src/main/java/org/teasoft/bee/osql/BeeAbstractFactory.java index a79943ba55006a4d27ebf31fd17eae8b3579ad56..f9500b3895580366fb827e2ab59a2b96dd28d43f 100644 --- a/src/main/java/org/teasoft/bee/osql/BeeAbstractFactory.java +++ b/src/main/java/org/teasoft/bee/osql/BeeAbstractFactory.java @@ -24,7 +24,7 @@ import javax.sql.DataSource; import org.teasoft.bee.osql.transaction.Transaction; /** - * 关于数据源和事务的抽象基类.An abstract super class about DataSource and Transaction. + * An abstract super class about DataSource and Transaction. * @author Kingstar * @since 1.0 */ diff --git a/src/main/java/org/teasoft/bee/osql/BeeException.java b/src/main/java/org/teasoft/bee/osql/BeeException.java index 6ef5bcea368504ca241095dac67cee4317a52a1d..1a4a532b1932048a015e48d89b1687ea98875bb9 100644 --- a/src/main/java/org/teasoft/bee/osql/BeeException.java +++ b/src/main/java/org/teasoft/bee/osql/BeeException.java @@ -18,7 +18,7 @@ package org.teasoft.bee.osql; /** - * Bee的异常父类.Bee's super exception class. + * Bee's super exception class. * @author Kingstar * @since 1.4 */ diff --git a/src/main/java/org/teasoft/bee/osql/BeeExtCache.java b/src/main/java/org/teasoft/bee/osql/BeeExtCache.java new file mode 100644 index 0000000000000000000000000000000000000000..29775d54de5549c224acbfbaf9d4bd730e23cb01 --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/BeeExtCache.java @@ -0,0 +1,47 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql; + +/** + * Ext Cache interface. + * @author Kingstar + * @since 1.11 + */ +public interface BeeExtCache extends Cache{ + + /** + * Get the cache result by key(sql). + * @param key cache key,normally it is sql. + * @return result record + */ + public Object getInExtCache(String key); + + /** + * Put the result in the cache identify with key(sql). + * @param key cache key,normally it is sql. + * @param result result record + */ + public void addInExtCache(String key, Object result); + + /** + * Clear the cache result of related table by key(sql). + * @param key cache key,normally it is sql. + */ + public void clearInExtCache(String key); + +} diff --git a/src/main/java/org/teasoft/bee/osql/BeeSQLException.java b/src/main/java/org/teasoft/bee/osql/BeeSQLException.java index 2066028c5f294fe17d8a7f8327b7b4b7f903b59b..32ca1ba149fb161f3665944ce197733248dbdc59 100644 --- a/src/main/java/org/teasoft/bee/osql/BeeSQLException.java +++ b/src/main/java/org/teasoft/bee/osql/BeeSQLException.java @@ -18,7 +18,7 @@ package org.teasoft.bee.osql; /** - * Bee的SQL异常父类.Bee's SQL super exception class. + * Bee's SQL super exception class. * @author Kingstar * @since 1.4 */ diff --git a/src/main/java/org/teasoft/bee/osql/BeeSql.java b/src/main/java/org/teasoft/bee/osql/BeeSql.java index 3a6a14660a7b32357dd1cb7b415e77365f56b690..7027b6bf146a5e480a8ec5b546367d88f7505ca9 100644 --- a/src/main/java/org/teasoft/bee/osql/BeeSql.java +++ b/src/main/java/org/teasoft/bee/osql/BeeSql.java @@ -21,12 +21,10 @@ import java.util.List; import java.util.Map; /** - * 直接用sql语句操作数据库的接口 - *
在该接口中的sql字符串要是DB能识别的SQL语句 - *
该接口为Bee框架使用的底层接口,不建议用户直接使用 - *
The interface of operating database with SQL statement directly - *
The SQL string in this interface is the SQL statement that DB can recognize - *
BeeSql is the underlying interface used by Bee framework, and it is not recommended for users to use it directly + * The interface of operating database with SQL statement directly. + *
The SQL string in this interface is the SQL statement that DB can recognize. + *
BeeSql is the underlying interface used by Bee framework, and it is not + *
recommended for users to use it directly. * @author Kingstar * Create on 2013-6-30 22:05:36 * @since 1.0 @@ -34,92 +32,90 @@ import java.util.Map; public interface BeeSql { /** - * 根据sql查询数据,数据类型与entity类型一致 - *
According to SQL query data, data type is consistent with entity type. + * According to SQL query data, data type is consistent with entity type. * @param sql SQL select statement - * @param entity 与表对应的实体对象,且不能为空 - * entity corresponding to table and can not be null. - * @return 可包含多个实体(多条记录)的list. list can contain more than one entity. + * @param entity The entity corresponding to table and can not be null. + * @return List can contain more than one entity. */ public List select(String sql,T entity ); /** - * 多表查询的方法.根据sql查询数据,数据类型与entity类型一致 - *
According to SQL query more table data, data type is consistent with entity type. + * According to SQL query more table data, data type is consistent with entity type. * @param sql SQL select statement - * @param entity 与表对应的实体对象,且不能为空 - * entity corresponding to table and can not be null. - * @return 可包含多个实体(多条记录)的list. list can contain more than one entity. + * @param entity The entity corresponding to table and can not be null. + * @return List can contain more than one entity. * @since 1.7 */ public List moreTableSelect(String sql,T entity ); /** - * 查询部分字段.Select some field. + * Select some field. * @param sql SQL select statement - * @param entity - * @return entity的list,这些entity只有查询的部分字段会设值.list entity which just has some field. + * @param entity The entity corresponding to table and can not be null. + * @return List entity which just has some field. */ public List selectSomeField(String sql,T entity ); /** - * 用函数查询结果.Select result with function. SQL function: max,min,avg,sum,count. + * Select result with function. SQL function: max,min,avg,sum,count. * @param sql SQL select statement - * @return 函数统计的值.如果统计的结果集为空,除了count返回0,其它都返回空字符. + * @return The value of function statistics. + *
If the result set of statistics is empty,the count return 0,the other return empty string. + * */ public String selectFun(String sql) ; /** - * 查询并将每一行结果转成String数组.Select and transform every record to string array. + * Select and transform every record to string array. * @param sql SQL select statement - * @return List,每个元素是一行记录转换成的string数组. - * List, every element is string array(transform from record). + * @return List, every element is string array(transform from record). */ public List select(String sql); /** - * 查询并将每一行结果转成Map.Select and transform every record to Map. + * Select and transform every record to Map. * @param sql SQL select statement - * @return List,每个元素是一行记录转换成的Map. - * List, every element is a Map(transform from record). + * @return List, every element is a Map(transform from record). * @since 1.9 */ public List> selectMapList(String sql); /** - * 查询结果,并以json格式返回.Select and return json format result. + * Select and return json format result. * @param sql SQL select statement - * @return json格式结果集.json format result . + * @return json format result . */ public String selectJson(String sql); /** - * 操作update,insert,delete.对应Jdbc的executeUpdate方法 - *
Operate update,insert,delete. corresponding to Jdbc executeUpdate method. + * Operate update,insert,delete. corresponding to Jdbc executeUpdate method. * @param sql SQL statement to execute - * @return 成功操作的记录行数. the number of affected successfully records. + * @return the number of affected successfully records. */ public int modify(String sql); + /** + * insert and return the value of primary key. + * @param sql SQL statement to execute + * @return the value of primary key. + */ public long insertAndReturnId(String sql); /** - * 提交一批命令到数据库 * Submits a batch of commands to the database. - * @param sqls 要执行的sql语句数组 Array of SQL statements to execute - * @return 受影响的行数 Affected rows. + * @param sqls Array of SQL statements to execute + * @return Affected rows. */ public int batch(String sqls[]); /** - * 提交一批命令到数据库 * Submits a batch of commands to the database. - * @param sqls 要执行的sql语句数组 Array of SQL statements to execute - * @param batchSize 一个批次提交的命令数目 the size of commands in a batch - * @return 受影响的行数 Affected rows. + * @param sqls Array of SQL statements to execute + * @param batchSize the size of commands in a batch + * @return Affected rows. */ public int batch(String []sqls,int batchSize); } diff --git a/src/main/java/org/teasoft/bee/osql/BeeVersion.java b/src/main/java/org/teasoft/bee/osql/BeeVersion.java new file mode 100644 index 0000000000000000000000000000000000000000..d1a34450d297149558aab1373bea123e08ac9f07 --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/BeeVersion.java @@ -0,0 +1,21 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * The license,see the LICENSE file. + */ + +package org.teasoft.bee.osql; + +/** + * Bee Version. + * @author Kingstar + * @since 1.11 + */ +public final class BeeVersion { + + public static final String version = "V1.11"; + public static final String buildId = "V1.11.0.4.22"; + + private BeeVersion() {} + +} diff --git a/src/main/java/org/teasoft/bee/osql/Cache.java b/src/main/java/org/teasoft/bee/osql/Cache.java index 03030d46d444ccc06ea63f01999299597759016f..651d7b7f3a85ce133ac09a794eec6fd91978c996 100644 --- a/src/main/java/org/teasoft/bee/osql/Cache.java +++ b/src/main/java/org/teasoft/bee/osql/Cache.java @@ -18,8 +18,7 @@ package org.teasoft.bee.osql; /** - * 缓存接口.Cache interface. - *
通过sql生成缓存的key,然后再操作缓存. + * Cache interface. *
Gen the key via sql string, then operate the cache by the key. * @author Kingstar * @since 1.4 @@ -27,25 +26,22 @@ package org.teasoft.bee.osql; public interface Cache { /** - * 通过查询用的sql获取缓存结果记录 * Get the cache result by sql. - * @param sql 查询用的sql - * @return 缓存的结果集.cache result set. + * @param sql sql for select + * @return cache result set. */ public Object get(String sql); /** - * 将结果集放入缓存 * Put the result in the cache identify with sql. - * @param sql 查询用的sql - * @param resultSet 结果记录 + * @param sql sql for select + * @param result result of select */ - public void add(String sql,Object resultSet); + public void add(String sql,Object result); /** - * 清除某个表相关的缓存 * Clear the cache result of related table by sql. - * @param sql 会更新表数据的sql + * @param sql sql for modify */ public void clear(String sql); diff --git a/src/main/java/org/teasoft/bee/osql/CallableSql.java b/src/main/java/org/teasoft/bee/osql/CallableSql.java index 007c8d9224878b8a98f1fdecde9b69d0102a0b2b..0bdb21ca4229d68a4f1d3fdea1487c7a48a7c6c8 100644 --- a/src/main/java/org/teasoft/bee/osql/CallableSql.java +++ b/src/main/java/org/teasoft/bee/osql/CallableSql.java @@ -21,58 +21,59 @@ import java.sql.CallableStatement; import java.util.List; /** - * 存储过程方式Sql操作DB的接口.Procedure sql operate the DB. + * Procedure sql operate the DB. * @author Kingstar * @since 1.0 */ public interface CallableSql { /** - * + * Use Procedure to query data. * @param callSql procedure sql - * @param entity - * @param preValues parameter,just support In type; 只支持in类型的参数 - * @return 可包含多个实体(多条记录)的list. list which contains more than one entity. + * @param returnType entity Type,just for return type. + * @param preValues parameter,just support In type. + * @return list which contains more than one entity. */ - public List select(String callSql,T entity,Object preValues[]); + public List select(String callSql,T returnType,Object preValues[]); /** - * + * Use Procedure to query data. * @param callSql procedure sql,eg: procedure_name(?) - * @param preValues parameter,just support In type; 只支持in类型的参数 - * @return 可包含多个String数组结构的多条记录的list. list can contain more than one record with String array struct. + * @param preValues parameter,just support In type. + * @return list can contain more than one record with String array struct. */ public List select(String callSql,Object preValues[]); /** - * + * Use Procedure to query data and return Json string. * @param callSql procedure sql,eg: procedure_name(?) - * @param preValues parameter,just support In type; 只支持in类型的参数 - * @return 可包含多个实体(多条记录)的list转换成的json格式的字符串. Json string, it transform from list which can contain more than one entity. + * @param preValues parameter,just support In type. + * @return Json string, it transform from list which can contain more than one entity. * @since 1.1 */ public String selectJson(String callSql,Object preValues[]); /** - * + * Use Procedure to query data. * @param callSql procedure sql,eg: procedure_name(?) - * @param preValues parameter,just support In type; 只支持in类型的参数 - * @return 成功操作的记录行数. the number of affected successfully records. + * @param preValues parameter,just support In type. + * @return the number of affected successfully records. */ public int modify(String callSql,Object preValues[]); /** - * 返回CallableStatement对象以便可以设置in,out,inout参数.可方便调用JDBC底层的方法 + * Returns the instance of CallableStatement so that the in, out, inout parameters can be set. + *
It is convenient to call the underlying methods of JDBC * @param callSql procedure sql,eg: procedure_name(?) * @return CallableStatement. */ public CallableStatement getCallableStatement(String callSql); /** - * 对于有out或inout类型的参数,可设置参数后,再调用该方法. - * @param cstmt - * @return 成功操作的记录行数. the number of affected successfully records. + * For parameters with out or inout type, the method can be called after setting the parameters. + * @param cstmt instance of CallableStatement + * @return the number of affected successfully records. */ public int modify(CallableStatement cstmt); diff --git a/src/main/java/org/teasoft/bee/osql/CommOperate.java b/src/main/java/org/teasoft/bee/osql/CommOperate.java new file mode 100644 index 0000000000000000000000000000000000000000..ebc819fe6e9fc852bcbbe09afe24b826ff1fada4 --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/CommOperate.java @@ -0,0 +1,54 @@ +/* + * Copyright 2020-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql; + +import org.teasoft.bee.osql.interccept.InterceptorChain; + +/** + * Common operate interface about Suid. + * @author Kingstar + * @since 1.11 + */ +public interface CommOperate { + + /** + * Set the dataSource for current instance. If use the default settings that are not required. + * Set dataSource name (corresponding data source must be defined). + * @param dsName dataSource name + */ + public void setDataSourceName(String dsName); + + /** + * get DataSource name which set for current instance. + * @return DataSource name + */ + public String getDataSourceName(); + + /** + * Get the Interceptor chain, which can be used for a generated object set a specific interceptor. + * @return InterceptorChain + */ + public InterceptorChain getInterceptorChain(); + + /** + * Set the NameTranslate for current instance. + * If use the default settings that are not required. + * @param nameTranslate nameTranslate + */ + public void setNameTranslate(NameTranslate nameTranslate); +} diff --git a/src/main/java/org/teasoft/bee/osql/Condition.java b/src/main/java/org/teasoft/bee/osql/Condition.java index 021a99295811d8134f81583e6cfe4a36a63fc9bf..65761629d1ffc772fa6fcfbb597e78dd9d70bcc7 100644 --- a/src/main/java/org/teasoft/bee/osql/Condition.java +++ b/src/main/java/org/teasoft/bee/osql/Condition.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 the original author.All rights reserved. + * Copyright 2016-2022 the original author.All rights reserved. * Kingstar(honeysoft@126.com) * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,36 +18,37 @@ package org.teasoft.bee.osql; /** - * 为面向对象方式操作数据库提供封装的条件.Condition for operate DB with Object Oriented Programming way. - *
用户需要保证SQL的书写顺序,如order by应在group by的后面. - *
setMultiply,setAdd,set等方法仅用于SQL Update语句的set部分. + * Condition for operate DB with Object Oriented Programming way. *
Users need to ensure the order of SQL writing, such as order by should be behind group by. *
The methods setMultiply,setAdd,set just use in SQL Update 'set' part. + *
Field name will be translated according the config. * @author Kingstar * @since 1.6 */ public interface Condition extends ConditionAssistant { /** - * 添加用于分页时设置开始的页数(仅用于SQL的select).For setting the start of the page(only for select of SQL). - *
无书写顺序限制.There is no restriction on writing order. - * @param start 开始下标(从0或1开始,eg:MySQL是0,Oracle是1). start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). + * For setting the start of the page(only for select of SQL). + *
There is no restriction on writing order. + * @param start Start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). * @return Condition */ public Condition start(Integer start); /** - * 添加用于分页时设置每页返回的记录数量(仅用于SQL的select).For setting the size of the page(only for select of SQL). - *
无书写顺序限制.There is no restriction on writing order. - * @param size 结果集大小 大于等于1. fetch result size (>0). + * For setting the size of the page(only for select of SQL). + * There is no restriction on writing order. + * @param size Fetch result size (>0). * @return Condition */ public Condition size(Integer size); /** - * 设置IncludeType过滤参数.op,between,notBetween方法设置的字段,不受includeType的值影响.Set IncludeType. - *
如果Condition没有使用该方法设置,则按默认过滤方式处理. - *
无书写顺序限制.There is no restriction on writing order. + * Set the IncludeType filter parameter. The fields set by op, between and + *
notbetween methods are not affected by the value of IncludeType. + *
If the condition is not set with this method, it will be processed + *
according to the default filtering method. + *
There is no restriction on writing order. * @param includeType * @return Condition * @since 1.7 @@ -55,67 +56,67 @@ public interface Condition extends ConditionAssistant { public Condition setIncludeType(IncludeType includeType); /** - * 添加一个表达式条件.Add a expression condition. - *
此方法不能用于SQL的update set. - * @param field 字段名.field name - * @param Op 操作符.operator. - * @param value 字段对应的值.value of the field. + * Add a expression condition. + *
This method cannot be used for SQL update set part. + * @param field Field name + * @param op operator + * @param value Value of the field. * @return Condition */ - public Condition op(String field, Op Op, Object value); + public Condition op(String field, Op op, Object value); /** - * 表达式将对应 table1 JoinType table2 on field Op value - * eg: opOn("table2.valid",Op.eq,"1") table1 left join table2 on table1.id=table2.id and table2.valid='1' - * it is different from where part: table1 left join table2 on table1.id=table2.id where valid='1' - * @param field - * @param Op 操作符.operator. - * @param value 字段对应的值.value of the field. + * The expression will correspond to: table1 JoinType table2 on field Op value + *
eg: opOn("table2.valid",Op.eq,"1") table1 left join table2 on table1.id=table2.id and table2.valid='1' + *
it is different from where part: table1 left join table2 on table1.id=table2.id where valid='1' + * @param field Field name + * @param op operator + * @param value Value of the field. * @return Condition */ - public Condition opOn(String field, Op Op, Object value); + public Condition opOn(String field, Op op, Object value); /** - * 添加一个表达式条件.Add a expression condition. - *
此方法不能用于SQL的update set. - * eg: opWithField(field1,Op.gt,field2)-->where field1>field2 - * @param field1 first field - * @param Op 操作符.operator. - * @param field2 second field + * Add a expression condition. + *
This method cannot be used for SQL update set part. + *
eg: opWithField(field1,Op.gt,field2)-->where field1>field2 + * @param field1 first field name + * @param op operator + * @param field2 second field name * @return Condition * @since 1.9 */ - public Condition opWithField(String field1, Op Op, String field2); + public Condition opWithField(String field1, Op op, String field2); /** - * 默认自动加 'and'.Default will automatically add 'and'. + * Default will automatically add 'and'. * * @return Condition */ public Condition and(); /** - * 添加 'or'.Add 'or'. + * Add 'or'. * * @return Condition */ public Condition or(); /** - * 添加左括号.Add left parentheses. + * Add left parentheses. * @return Condition */ public Condition lParentheses(); /** - * 添加右括号.Add right parentheses. + * Add right parentheses. * @return Condition */ public Condition rParentheses(); /** - * + * transform to: field between low and high; * @param field * @param low * @param high @@ -133,7 +134,7 @@ public interface Condition extends ConditionAssistant { public Condition notBetween(String field, Number low, Number high); /** - * between + * field between 'low' and 'high'; * @param field * @param low * @param high @@ -157,79 +158,68 @@ public interface Condition extends ConditionAssistant { */ public Condition groupBy(String field); - /** - * eg:having("count(*)>5") --> having count(*)>5 - * @param expressionStr 表达式字符串,field不会被转化. - * expression string,if contain field,it will not be translated. - * @return Condition - */ -// public Condition having(String expressionStr); - //closed. because can use: -// .having(FunctionType.COUNT, "*", Op.ge, 1) -// .having(FunctionType.COUNT, "distinct(userid)", Op.ge, 1) - /** * having - * eg: having(FunctionType.MIN, "field", Op.ge, 60)-->having min(field)>=60 - * @param functionType SQL函数类型 - * @param field 实体字段,会被命名转换(如果需要). - * @param Op 操作类型 - * @param value 值 + *
eg: having(FunctionType.MIN, "field", Op.ge, 60)-->having min(field)>=60 + * @param functionType FunctionType + * @param field Entity field,it will be translated according the config. + * @param op operator + * @param value Value of the field. * @return Condition */ - public Condition having(FunctionType functionType, String field, Op Op, Number value); + public Condition having(FunctionType functionType, String field, Op op, Number value); /** * order by - * eg: orderBy("price")-->order by price - * @param field 用于排序的字段名.field name. + *
eg: orderBy("price")-->order by price + * @param field field name. * @return Condition */ public Condition orderBy(String field); /** * order by - * eg: orderBy("price", OrderType.DESC)-->order by price desc - * @param field 用于排序的字段名.field name. - * @param orderType 排序类型(asc或desc). order type(asc or desc) + *
eg: orderBy("price", OrderType.DESC)-->order by price desc + * @param field Field name. + * @param orderType order type(asc or desc) * @return Condition */ public Condition orderBy(String field, OrderType orderType); /** * order by - * eg: orderBy(FunctionType.MAX, "total", OrderType.DESC)-->order by max(total) desc - * @param functionType SQL函数类型.Function type of SQL. - * @param field 用于排序的字段名.field name. - * @param orderType 排序类型(asc或desc). order type(asc or desc) + *
eg: orderBy(FunctionType.MAX, "total", OrderType.DESC)-->order by max(total) desc + * @param functionType Function type of SQL. + * @param field Field name. + * @param orderType order type(asc or desc) * @return Condition */ public Condition orderBy(FunctionType functionType, String field, OrderType orderType); /** - * 设置需要更新的字段(仅用于SQL的update set),字段在自身基础上变化.Set the fields to be updated (for only update of SQL),and the field change on itself. + * Set the fields to be updated (for only update of SQL),and the field change on itself. *
eg: setAdd("price",2.0)--> price=price+2.0 - * @param field - * @param num + * @param field Field name. + * @param num number * @return Condition * @since 1.7.2 */ public Condition setAdd(String field,Number num); /** - * 设置需要更新的字段(仅用于SQL的update set),字段在自身基础上变化.Set the fields to be updated (for only update of SQL),and the field change on itself. + * Set the fields to be updated (for only update of SQL),and the field change on itself. *
eg: setMultiply("price",1.05)--> price=price*1.05 - * @param field - * @param num + * @param field Field name. + * @param num number * @return Condition * @since 1.7.2 */ public Condition setMultiply(String field,Number num); /** - * 设置需要更新的字段(仅用于SQL的update set),字段在自身基础上变化.Set the fields to be updated (for only update of SQL),and the field change on itself. + * Set the fields to be updated (for only update of SQL),and the field change on itself. *
eg:setAdd("price","delta")--> price=price+delta - * @param field + * @param field Field name. * @param otherFieldName * @return Condition * @since 1.8 @@ -237,9 +227,9 @@ public interface Condition extends ConditionAssistant { public Condition setAdd(String field, String otherFieldName); /** - * 设置需要更新的字段(仅用于SQL的update set),字段在自身基础上变化.Set the fields to be updated (for only update of SQL),and the field change on itself. + * Set the fields to be updated (for only update of SQL),and the field change on itself. *
eg: setMultiply("price","delta")--> price=price*delta - * @param field + * @param field Field name. * @param otherFieldName other fieldName * @return Condition * @since 1.8 @@ -247,21 +237,21 @@ public interface Condition extends ConditionAssistant { public Condition setMultiply(String field, String otherFieldName); /** - * 设置需要更新的字段(仅用于SQL的update set);当要更新的字段也需要用于where条件时,可用该方法 - *
Set the fields that need to be updated (only for update of SQL ); this method can be used when the set fields also need to be used for the where expression. - *
eg: set("maxid", 1000)-->maxid=1000 + * Set the fields that need to be updated (only for update of SQL ); + *
this method can be used when the set fields also need to be used for the where expression. + *
eg: set("maxid", 1000)-->update table_name set maxid=1000 * @param fieldName field name - * @param num + * @param num number * @return Condition * @since 1.8 */ public Condition set(String fieldName, Number num); /** - * 设置需要更新的字段(仅用于SQL的update set);当要更新的字段也需要用于where条件时,可用该方法 - *
Set the fields that need to be updated (only for update of SQL); this method can be used when the set fields also need to be used for the where expression. + * Set the fields that need to be updated (only for update of SQL); + *
this method can be used when the set fields also need to be used for the where expression. *
eg: set("name", 'bee')-->name='bee' - * @param fieldName + * @param fieldName Field name * @param value * @return Condition * @since 1.8 @@ -271,65 +261,66 @@ public interface Condition extends ConditionAssistant { /** * set one field with other field value - * eg: setWithField(field1,field2)--> set field1=field2 - * @param field1 first field - * @param field2 second field + *
eg: setWithField(field1,field2)--> set field1=field2 + * @param field1 first field name + * @param field2 second field name * @return Condition * @since 1.9 */ public Condition setWithField(String field1, String field2); /** - * 指定需要查询的部分字段(仅用于SQL的select).Specify the partial fields to be queried (only for select of SQL). - * @param fieldList 需要查询的字段,多个用逗号隔开. select fields,if more than one,separate with comma. + * Specify the partial fields to be queried (only for select of SQL). + * @param fieldList select fields,if more than one,separate with comma or use variable-length arguments. * @return Condition * @since 1.8 + * @since 1.11 support variable-length arguments */ - public Condition selectField(String fieldList); + public Condition selectField(String... fieldList); /** - * 设置字段fieldName为distinct(fieldName) - * eg: selectDistinctField(fieldName) --> distinct(fieldName) - * @param fieldName 要设置为distinct的字段 + * set fieldName for distinct(fieldName) + *
eg: selectDistinctField(fieldName) --> distinct(fieldName) + * @param fieldName Field name * @return Condition * @since 1.9 */ public Condition selectDistinctField(String fieldName); /** - * 设置字段fieldName为distinct(fieldName) + * set fieldName for distinct(fieldName) * eg: selectDistinctField(fieldName,alias) --> distinct(fieldName) as alias - * @param fieldName 要设置为distinct的字段 - * @param alias 别名 + * @param fieldName Field name + * @param alias Name of alias * @return Condition * @since 1.9 */ public Condition selectDistinctField(String fieldName, String alias); /** - * 设置使用函数查询结果.set select result with function. + * set for select result with function. *
eg: condition.selectFun(FunctionType.COUNT, "*");-->count(*) - * @param functionType SQL函数类型.Function type of SQL. - * @param fieldForFun 用于函数统计的字段名.field name for function. + * @param functionType Function type of SQL. + * @param fieldForFun Field name for function. * @return Condition * @since 1.9 */ public Condition selectFun(FunctionType functionType, String fieldForFun); /** - * 设置使用函数查询结果.set select result with function. + * set for select result with function. *
eg:selectFun(FunctionType.MAX, "score","maxScore")-->max(score) as maxScore - * @param functionType SQL函数类型.Function type of SQL. - * @param fieldForFun 用于函数统计的字段名.field name for function. - * @param alias 统计结果的别名.alias name for the function result. + * @param functionType Function type of SQL. + * @param fieldForFun field name for function. + * @param alias Name of alias for the function result. * @return Condition * @since 1.9 */ public Condition selectFun(FunctionType functionType, String fieldForFun, String alias); /** - * 锁定查询的部分记录(仅用于SQL的单个表select).lock the select record with 'for update'. - *
无书写顺序限制.There is no restriction on writing order. + * lock the select record with 'for update'. + *
There is no restriction on writing order. * @return Condition * @since 1.8 */ diff --git a/src/main/java/org/teasoft/bee/osql/ConditionAssistant.java b/src/main/java/org/teasoft/bee/osql/ConditionAssistant.java index dae5f926e3a4a376a08dd6ae7ff03f1e63a760e7..cd1559d7d38df185cac589a0517b412237dd3f38 100644 --- a/src/main/java/org/teasoft/bee/osql/ConditionAssistant.java +++ b/src/main/java/org/teasoft/bee/osql/ConditionAssistant.java @@ -20,20 +20,19 @@ package org.teasoft.bee.osql; import java.util.Set; /** - * Condition的辅助接口.Assistant of Condition. + * Assistant of Condition. * @author Kingstar * @since 1.6 */ -//用于不需要放在Condition链式编程的方法 public interface ConditionAssistant { /** - * Condition的whereField已包含的字段,默认情况不再遍历.If the field use in Condition,it would not be processed again in default. - * @return 返回用于where Condition表达式的字段集合. + * If the field use in Condition,it would not be processed again in default. + * @return Returns fields collection for where condition expression. */ public Set getWhereFields(); - void setSuidType(SuidType SuidType); + void setSuidType(SuidType suidType); /** * @@ -49,7 +48,7 @@ public interface ConditionAssistant { */ public Set getUpdatefields(); - public String getSelectField(); + public String[] getSelectField(); public Boolean getForUpdate(); } diff --git a/src/main/java/org/teasoft/bee/osql/DatabaseConst.java b/src/main/java/org/teasoft/bee/osql/DatabaseConst.java index 3a85b337773951f65452c2b0cd129c233de03e61..704dfd1844a28c9b3539359c31ec4bc8b66f7d15 100644 --- a/src/main/java/org/teasoft/bee/osql/DatabaseConst.java +++ b/src/main/java/org/teasoft/bee/osql/DatabaseConst.java @@ -1,7 +1,7 @@ package org.teasoft.bee.osql; /** - * 数据库名称常量.Database Name Const. + * Database Name Const. * @author Kingstar * @since 1.0 */ @@ -37,5 +37,13 @@ public final class DatabaseConst { public static final String Sybase = "Sybase SQL Server"; public static final String Teradata = "Teradata"; public static final String TimesTen = "TimesTen"; + + //NoSql + public static final String Cassandra = "Cassandra"; + public static final String Hbase = "Hbase"; + public static final String Hypertable= "Hypertable"; + + public static final String MongoDB= "MongoDB"; + public static final String CouchDB = "CouchDB"; } diff --git a/src/main/java/org/teasoft/bee/osql/FunctionType.java b/src/main/java/org/teasoft/bee/osql/FunctionType.java index 6e075a78a56858220d61bcfb35d4a5220eee8138..27d6f869b9c2b05684a7da2f2e830d78610f9bff 100644 --- a/src/main/java/org/teasoft/bee/osql/FunctionType.java +++ b/src/main/java/org/teasoft/bee/osql/FunctionType.java @@ -1,7 +1,7 @@ package org.teasoft.bee.osql; /** - * SQL对应的函数类型.Function type of SQL. + * Function type of SQL. * @author Kingstar * @since 1.0 */ diff --git a/src/main/java/org/teasoft/bee/osql/IncludeType.java b/src/main/java/org/teasoft/bee/osql/IncludeType.java index f068d5c063f11f4593e646ea76a2f3f3f236b2e6..dab39e1d96efb5b08a38ac6536e2e775ea446d29 100644 --- a/src/main/java/org/teasoft/bee/osql/IncludeType.java +++ b/src/main/java/org/teasoft/bee/osql/IncludeType.java @@ -1,13 +1,12 @@ package org.teasoft.bee.osql; /** - * 包含类型:关于Null和空字符的.Include type about Null and empty string. + * Include type about Null and empty string. * @author Kingstar * @since 1.0 */ public enum IncludeType { - // -1 for both exclude 留用 /** * exclude: NULL and "" */ diff --git a/src/main/java/org/teasoft/bee/osql/LowerKey.java b/src/main/java/org/teasoft/bee/osql/LowerKey.java index f5ab0e533631f3f6e01a8fdc632bccbb4c96aa0a..dcf68f41480780b30a4ce79514393fb8e74c0f25 100644 --- a/src/main/java/org/teasoft/bee/osql/LowerKey.java +++ b/src/main/java/org/teasoft/bee/osql/LowerKey.java @@ -18,58 +18,59 @@ package org.teasoft.bee.osql; /** - * SQL关键字的小写形式.SQL KeyWord's lower case. + * SQL KeyWord's lower case. * @author Kingstar * @since 1.8.99 */ public class LowerKey implements SqlKeyWord { - - private static final String SPACE=" "; - private static final String select="select"; - private static final String as="as"; - private static final String from="from"; - private static final String where="where"; - private static final String insert="insert"; - private static final String into="into"; - private static final String values="values"; - private static final String and="and"; - private static final String or="or"; - private static final String Null="null"; - private static final String isNull="is null"; - private static final String isNotNull="is not null"; - private static final String update="update"; - private static final String set="set"; - private static final String delete="delete"; - private static final String orderBy="order by"; - private static final String count="count"; - private static final String asc="asc"; - private static final String on="on"; - private static final String limit="limit"; - private static final String offset="offset"; - private static final String top="top"; - - private static final String groupBy="group by"; - private static final String having="having"; - private static final String between="between"; - private static final String notBetween="not between"; - - private static final String forUpdate="for update"; - - private static final String distinct="distinct"; - private static final String join="join"; - private static final String innerJoin="inner join"; - private static final String leftJoin="left join"; - private static final String rightJoin="right join"; - private static final String in="in"; - private static final String notIn="not in"; - private static final String exists="exists"; - private static final String notExists="not exists"; + + private static final String SPACE = " "; + private static final String select = "select"; + private static final String as = "as"; + private static final String from = "from"; + private static final String where = "where"; + private static final String insert = "insert"; + private static final String replace = "replace"; + private static final String into = "into"; + private static final String values = "values"; + private static final String and = "and"; + private static final String or = "or"; + private static final String Null = "null"; + private static final String isNull = "is null"; + private static final String isNotNull = "is not null"; + private static final String update = "update"; + private static final String set = "set"; + private static final String delete = "delete"; + private static final String orderBy = "order by"; + private static final String count = "count"; + private static final String asc = "asc"; + private static final String on = "on"; + private static final String limit = "limit"; + private static final String offset = "offset"; + private static final String top = "top"; + + private static final String groupBy = "group by"; + private static final String having = "having"; + private static final String between = "between"; + private static final String notBetween = "not between"; + + private static final String forUpdate = "for update"; + + private static final String distinct = "distinct"; + private static final String join = "join"; + private static final String innerJoin = "inner join"; + private static final String leftJoin = "left join"; + private static final String rightJoin = "right join"; + private static final String in = "in"; + private static final String notIn = "not in"; + private static final String exists = "exists"; + private static final String notExists = "not exists"; @Override public String select() { return select; } - + @Override public String as() { return as; @@ -90,6 +91,11 @@ public class LowerKey implements SqlKeyWord { return insert; } + @Override + public String replace() { + return replace; + } + @Override public String into() { return into; @@ -99,7 +105,7 @@ public class LowerKey implements SqlKeyWord { public String values() { return values; } - + @Override public String and() { return and; @@ -109,7 +115,7 @@ public class LowerKey implements SqlKeyWord { public String or() { return or; } - + @Override public String Null() { return Null; @@ -159,7 +165,7 @@ public class LowerKey implements SqlKeyWord { public String asc() { return asc; } - + @Override public String on() { return on; @@ -229,7 +235,7 @@ public class LowerKey implements SqlKeyWord { public String rightJoin() { return rightJoin; } - + @Override public String in() { return in; @@ -239,7 +245,7 @@ public class LowerKey implements SqlKeyWord { public String notIn() { return notIn; } - + @Override public String exists() { return exists; diff --git a/src/main/java/org/teasoft/bee/osql/MapSql.java b/src/main/java/org/teasoft/bee/osql/MapSql.java index c1d4b863dc811a0b24563998d79ad94e2f780413..54df9bb7308b4e403c470344a803d3262d8fdac8 100644 --- a/src/main/java/org/teasoft/bee/osql/MapSql.java +++ b/src/main/java/org/teasoft/bee/osql/MapSql.java @@ -20,21 +20,20 @@ package org.teasoft.bee.osql; import java.util.Map; /** - * 用Map承载SQL信息.Record SQL information with map. + * Record SQL information with map. * @author Kingstar * @since 1.9 */ public interface MapSql { /** - * 设置SQL用到的相关信息,Map的key由MapSqlKey提供.Set the relevant information used by SQL. The key of map is provided by MapSqlKey. - * @param MapSqlKey 设置的MapSqlKey Key + * Set the relevant information used by SQL. The key of map is provided by MapSqlKey. + * @param mapSqlKey MapSqlKey * @param value value */ - public void put(MapSqlKey MapSqlKey, String value); + public void put(MapSqlKey mapSqlKey, String value); /** - * 设置用于SQL select,delete,update中where过虑的字段信息;也可用于SQL insert,设置插入的字段及相应值 * Set the field information used for where filtering in SQL select,delete, also can use in SQL insert. * @param fieldName field name * @param value value @@ -42,14 +41,12 @@ public interface MapSql { public void put(String fieldName, Object value); /** - * 设置用于SQL select,delete,update中where过虑的字段信息;也可用于SQL insert,设置插入的字段及相应值 * Set the field information used for where filtering in SQL select,delete, also can use in SQL insert. - * @param map 字段和值组成的map对象 + * @param map map instance consist by key and value. */ public void put(Map map); /** - * 设置需要更新的字段和值,用于update的Set部分 * Set the fields and values that need to be updated for the set part of SQL update * @param fieldName * @param value @@ -58,30 +55,29 @@ public interface MapSql { public void putNew(String fieldName, Object value); /** - * 设置需要更新的字段和值,用于update SQL的Set部分 * Set the fields and values that need to be updated for the set part of SQL update - * @param map 需要更新的字段和值组成的map对象. A map object consisting of fields and values that need to be updated + * @param map A map object consisting of fields and values that need to be updated * @since 1.9.8 */ public void putNew(Map map); /** - * 设置用于过滤或处理规则的配置.Set the configuration for filtering or processing rule. - * @param MapSqlSetting 设置的MapSqlSetting Key - * @param value 设置的值 + * Set the configuration for filtering or processing rule. + * @param mapSqlSetting Key of MapSqlSetting + * @param value setting value */ - public void put(MapSqlSetting MapSqlSetting, boolean value); + public void put(MapSqlSetting mapSqlSetting, boolean value); /** - * 分页查询时,设置开始页.Set the start page when paging query. - * 当用于count()时,忽略此方法 + * Set the start page when paging query. + * It will be ignore when use count(). * @param start * @since 1.9.8 */ public void start(Integer start); /** - * 分页查询时,设置一页的数据记录数量.During paging query, set the number of data records on one page. - * 当用于count()时,忽略此方法 + * During paging query, set the number of data records on one page. + * It will be ignore when use count(). * @param size * @since 1.9.8 */ diff --git a/src/main/java/org/teasoft/bee/osql/MapSqlKey.java b/src/main/java/org/teasoft/bee/osql/MapSqlKey.java index 54edda2a3ee40b7f38d11a22b77bbe9e5be0e5fe..b4d6fb869967f472bbc4de28425b870d2554fc37 100644 --- a/src/main/java/org/teasoft/bee/osql/MapSqlKey.java +++ b/src/main/java/org/teasoft/bee/osql/MapSqlKey.java @@ -18,40 +18,43 @@ package org.teasoft.bee.osql; /** - * 用于MapSuid的对应SQL功能的MapSql关键字.MapSql keyword for the corresponding SQL function of MapSuid. + * MapSql keyword for the corresponding SQL function of MapSuid. * @author Kingstar * @since 1.9 */ public enum MapSqlKey { /** - * 声明需要操作的表.Declare the table to be operated on. + * Declare the table to be operated on. */ Table("Table"), /** - * 声明需要查询的字段,多个用逗号隔开.Declare the select fields,if more than one,separate with comma. + * In the method insertAndReturnId(MapSql mapSql) of MapSuid, it is used when the primary key name is not 'id'. + * @since 1.11 + */ + PrimaryKey("PrimaryKey"), + + /** + * Declare the select fields,if more than one,separate with comma. */ SelectColumns("SelectColumns"), /** - * 对应SQL的group by.It corresponds to the group by of SQL. + * It corresponds to the group by of SQL. */ GroupBy("GroupBy"), /** - * 对应SQL的having.It corresponds to the having of SQL. + * It corresponds to the having of SQL. */ Having("Having"), /** - * 对应SQL的order by.It corresponds to the order by of SQL. + * It corresponds to the order by of SQL. */ OrderBy("OrderBy") -// , -// Start("Start"), -// Size("Size"), ; String name; diff --git a/src/main/java/org/teasoft/bee/osql/MapSqlSetting.java b/src/main/java/org/teasoft/bee/osql/MapSqlSetting.java index a2ef4f4ade1dd23732b204170321a3bd8e83bfd1..d707911670a556e05f78f3223ba445f811b17199 100644 --- a/src/main/java/org/teasoft/bee/osql/MapSqlSetting.java +++ b/src/main/java/org/teasoft/bee/osql/MapSqlSetting.java @@ -18,15 +18,14 @@ package org.teasoft.bee.osql; /** - * 用于MapSuid的MapSql配置信息.MapSql configuration information for MapSuid. + * MapSql configuration information for MapSuid. * @author Kingstar * @since 1.9 */ public enum MapSqlSetting { /** - * 是否命名转换.Is naming transfer. value is 'true' or 'false',default is 'false' - * 真时,会根据配置的规则(可在bee.properties配置)进行转换;假时不转换. + * Is naming transfer. value is 'true' or 'false',default is 'false' * if true, will transfer by the rule (eg: bee.properties). if false,do not transfer. */ IsNamingTransfer("IsNamingTransfer") , @@ -38,8 +37,15 @@ public enum MapSqlSetting { /** * include empty string.value is 'true' or 'false',default is 'false' + * @since V1.11 */ - IsIncludeEmptyString("IsIncludeEmptyString") + IsIncludeEmptyString("IsIncludeEmptyString"), + + /** + * "true" and "false" String transfer to Boolean Type. + * It will be transfer by default. + */ + IsTransferTrueFalseStringToBooleanType("IsTransferTrueFalseStringToBooleanType") ; String name; diff --git a/src/main/java/org/teasoft/bee/osql/MapSuid.java b/src/main/java/org/teasoft/bee/osql/MapSuid.java index 3d5b2b97bc6e12dd1f55a5e1580af21c82837f6d..40cf84aef189d763a5693342be1117b38202a90e 100644 --- a/src/main/java/org/teasoft/bee/osql/MapSuid.java +++ b/src/main/java/org/teasoft/bee/osql/MapSuid.java @@ -21,89 +21,83 @@ import java.util.List; import java.util.Map; /** - * 使用Map而非Javabean实体的数据库操作接口,默认不处理null和空字符串(与Suid,SuidRich风格兼容) - *
Database operation interface using map instead of specific entity, + * Database operation interface using map instead of specific entity, *
the null and empty string are not handled by default. * Suid (select,update,insert,delete) * @author Kingstar * @since 1.9 */ -public interface MapSuid { +public interface MapSuid extends CommOperate { /** - * 使用MapSql查询数据.Use MapSql to select data. + * Use MapSql to select data. * @param mapSql MapSql instance - * @return List结构的多行记录. - *
the multi-line record of List structure. + * @return the multi-line record of List structure. */ public List selectString(MapSql mapSql); /** - * 使用MapSql查询数据.Use MapSql to select data. + * Use MapSql to select data. * @param mapSql MapSql instance - * @return Json格式的多行记录.multi-line record in Json format. + * @return multi-line record in Json format. */ public String selectJson(MapSql mapSql); /** - * 使用MapSql查询数据.Use MapSql to select data. + * Use MapSql to select data. *
one map element as : field-name:value * @param mapSql MapSql instance - * @return List>结构的多行记录. - *
the multi-line record of List> structure. + * @return the multi-line record of List> structure. */ public List> select(MapSql mapSql); /** - * 使用MapSql查询数据.Use MapSql to select data. + * Use MapSql to select data. *
one map element as : fieldName:value * @param mapSql MapSql instance - * @return 包装在一个Map中的一行数据.returns a row of data wrapped in a map. + * @return returns a row of data wrapped in a map. */ public Map selectOne(MapSql mapSql); /** - * 更新记录,并返回受影响的行数.Update the record and return the number of rows affected. + * Update the record and return the number of rows affected. * @param mapSql MapSql instance - * MapSql的put方法用于SQL语句的where部分,putNew用于update类型SQL的set部分. * MapSql' put method for SQL where part, putNew for update SQL 's set part. - * @return 成功更新的记录数,若失败则返回小于0的整数. the numbers of update records successfully,if fails, return integer less than 0. + * @return the numbers of update records successfully,if fails, return integer less than 0. * @since 1.9.8 */ public int update(MapSql mapSql); /** - * 插入并返回记录的id值.Insert and return the id value of the record. - * id值可由Bee自动生成分布式id. - *
注意:若id由DB生成,需考虑DB是否支持,且对应JDBC驱动要支持返回id. + * Insert and return the id value of the record. *
The ID value can be generated automatically by bee *
Note: if id is generated by DB, consider whether DB supports it, *
and the corresponding JDBC driver supports returning id. * @param mapSql MapSql instance - * @return 若成功,返回插入记录的id值;若失败则返回小于0的数. - *
If successful, return the id value of the inserted record; if fails, return number less than 0. + * @return If successful, return the id value of the inserted record; if fails, return number less than 0. */ public long insertAndReturnId(MapSql mapSql); /** - * 插入记录,并返回成功插入的记录数.Inserts record and returns the number of the record successfully inserted. + * Inserts record and returns the number of the record successfully inserted. * @param mapSql MapSql instance - * @return 成功插入的记录数,若失败则返回小于0的整数.the numbers of insert records successfully,if fails, return integer less than 0. + * @return the numbers of insert records successfully,if fails, return integer less than 0. */ public int insert(MapSql mapSql); /** - * 使用MapSql删除记录.Use MapSql to delete record. + * Use MapSql to delete record. * @param mapSql MapSql instance - * @return 成功删除的记录数,若失败则返回小于0的整数. the numbers of delete records successfully,if fails, return integer less than 0. + * @return the numbers of delete records successfully,if fails, return integer less than 0. */ public int delete(MapSql mapSql); /** - * 统计符合条件的记录数.count the number of qualified record. + * count the number of qualified record. * @param mapSql MapSql instance - * @return 符合条件的记录数,若失败则返回小于0的整数.the number of qualified record,if fails, return integer less than 0. + * @return the number of qualified record,if fails, return integer less than 0. * @since 1.9.8 */ public int count(MapSql mapSql); + } diff --git a/src/main/java/org/teasoft/bee/osql/MoreObjToSQL.java b/src/main/java/org/teasoft/bee/osql/MoreObjToSQL.java index 029f4484977cf85cd4a61968c88c30677dfcb0a5..34436e9bd29f056d058ca8de5ae7295b29f2e5e2 100644 --- a/src/main/java/org/teasoft/bee/osql/MoreObjToSQL.java +++ b/src/main/java/org/teasoft/bee/osql/MoreObjToSQL.java @@ -1,40 +1,39 @@ -/* - * Copyright 2016-2020 the original author.All rights reserved. - * Kingstar(honeysoft@126.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.teasoft.bee.osql; - -/** - * 将多表查询的实体转成SQL语句.Select of More Objects to SQL. - * @author Kingstar - * @since 1.7 - */ -public interface MoreObjToSQL { - - public String toSelectSQL(T entity); - - public String toSelectSQL(T entity, int start, int size); - - /** - * 根据entity和Condition转换成sql语句 - * @param entity 实体类对象,且不能为空. table's entity(do not allow null). - * @param condition 默认有值的字段会转成field=value的形式,其它形式可通过condition指定. - * if the field is not null or empty, it will be translate to field=value.Other can define with condition. - * @return Return the sql String. - */ - public String toSelectSQL(T entity, Condition condition); - -} +/* + * Copyright 2016-2020 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql; + +/** + * Select of More Objects to SQL. + * @author Kingstar + * @since 1.7 + */ +public interface MoreObjToSQL { + + public String toSelectSQL(T entity); + + public String toSelectSQL(T entity, int start, int size); + + /** + * Convert to SQL statement according to entity and condition. + * @param entity table's entity(do not allow null). + * @param condition if the field is not null or empty, it will be translate to field=value.Other can define with condition. + * @return the sql String. + */ + public String toSelectSQL(T entity, Condition condition); + +} diff --git a/src/main/java/org/teasoft/bee/osql/MoreTable.java b/src/main/java/org/teasoft/bee/osql/MoreTable.java index 20faec070fdd57cc66da260c1262b9163014106e..aae5ffcf79ca20619b6f2a14157ba8a47faff808 100644 --- a/src/main/java/org/teasoft/bee/osql/MoreTable.java +++ b/src/main/java/org/teasoft/bee/osql/MoreTable.java @@ -20,7 +20,7 @@ package org.teasoft.bee.osql; import java.util.List; /** - * 多表查询.More table select. + * More table select(multi-table query). *

* example1:

@@ -123,47 +123,41 @@ public class Orders{ * @author Kingstar * @since 1.7 */ -public interface MoreTable { +public interface MoreTable extends CommOperate { /** - * 根据实体对象entity查询数据 * According to entity object select records from database. - * @param entity 与表对应的实体对象,且不能为空. table's entity(do not allow null).
- * entity中非null且非空字符串作为过虑条件,操作符是等号.eg:field=value
+ * @param entity table's entity(do not allow null).
* entity corresponding to table and can not be null.
* If the field value is not null and not empty string as filter condition,
* the operator is equal sign.eg:field=value - * @return 返回可包含多个实体(多条记录)的list. return list can contain more than one entity + * @return list can contain more than one entity */ public List select(T entity); /** - * 根据实体对象entity查询数据 * According to entity object select records from database. - * @param entity 实体类对象,且不能为空. table's entity(do not allow null).
- * entity中非null且非空字符串作为过虑条件,操作符是等号.eg:field=value
+ * @param entity table's entity(do not allow null).
* entity corresponding to table and can not be null.
* If the field value is not null and not empty string as filter condition,
* the operator is equal sign.eg:field=value - * @param start 开始下标(从0或1开始,eg:MySQL是0,Oracle是1). start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). - * @param size 结果集大小 大于等于1. fetch result size (>0). - * @return 返回可包含多个实体(多条记录)的list. return list can contain more than one entity + * @param start Start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). + * @param size Fetch result size (>0). + * @return list can contain more than one entity */ public List select(T entity, int start, int size); /** - * 根据实体对象和Condition查询数据.Select the records according to entity and condition. - * @param entity 与表对应的实体对象,且不能为空. table's entity(do not allow null).
- * @param condition entity默认有值的字段会转成field=value的形式,其它形式可通过condition指定.
- * If the field of entity is not null or empty, it will be translate to field=value.Other can define with condition.
- * 若condition没有设置IncludeType,默认过滤NULL和空字符串(但condition中op,between,notBetween方法设置的字段,不受includeType的值影响.) - * @return 返回可包含多个实体(多条记录)的list. return list can contain more than one entity + * Select the records according to entity and condition. + * @param entity table's entity(do not allow null). + * @param condition If the field of entity is not null or empty, + *
it will be translate to field=value.Other can define with condition. + * @return list can contain more than one entity */ public List select(T entity, Condition condition); /** - * 为动态表名、实体名参数设置值.set dynamic parameter for dynamic table & entity name - *
本方法的调用要早于select等方法. + * set dynamic parameter for dynamic table & entity name *
This method is called earlier than the select methods. * @param para parameter name * @param value parameter value @@ -171,5 +165,5 @@ public interface MoreTable { * @since 1.9 */ public MoreTable setDynamicParameter(String para,String value); - + } diff --git a/src/main/java/org/teasoft/bee/osql/NameTranslate.java b/src/main/java/org/teasoft/bee/osql/NameTranslate.java index 7e0d7bf4bcfc699d0eaba2e3a6e6d2f99794eb99..912e33b9bdc61c870ac9aaca67e8d12bcaffd163 100644 --- a/src/main/java/org/teasoft/bee/osql/NameTranslate.java +++ b/src/main/java/org/teasoft/bee/osql/NameTranslate.java @@ -18,14 +18,15 @@ package org.teasoft.bee.osql; /** - * 表名与实体名,列名与字段名互转.table name<-->entity name, coloumn name<-->field name. + * Table name and entity name, column name and field name are transferred to each other. + * table name<-->entity name, coloumn name<-->field name. * @author Kingstar * @since 1.5 */ public interface NameTranslate { /** - * 将Java实体名转成DB表名.Entity name to table name. + * Entity name to table name. * @param entityName * @return table name. */ @@ -33,15 +34,15 @@ public interface NameTranslate { /** - * 将Java实体类的字段名转成DB表的列名.Field name to column name. - * @param fieldName field name in Java entity. Java里实体类的字段名 + * Field name to column name. + * @param fieldName field name in Java entity. * @return column name. */ public String toColumnName(String fieldName); /** - * 将DB表名转成Java实体名.Table name to entity name. + * Table name to entity name. * @param tableName * @return entity name(Javabean name). */ @@ -49,8 +50,8 @@ public interface NameTranslate { /** - * 将DB表的列名转成Java里实体类的字段名.Column name to field name. - * @param columnName DB table's column name. DB表的列名 + * Column name to field name. + * @param columnName DB table's column name. * @return Javabean's field name. */ public String toFieldName(String columnName); diff --git a/src/main/java/org/teasoft/bee/osql/ObjSQLException.java b/src/main/java/org/teasoft/bee/osql/ObjSQLException.java index 90b1e14642ff5eb1b2b95c9be620f0f7eaec11cf..54d2cab78bbf309e05dafb49c00e6a46dbbff047 100644 --- a/src/main/java/org/teasoft/bee/osql/ObjSQLException.java +++ b/src/main/java/org/teasoft/bee/osql/ObjSQLException.java @@ -1,7 +1,7 @@ package org.teasoft.bee.osql; /** - * Bee的面向对象SQL异常父类.Bee's Object SQL super exception class. + * Bee's Object SQL super exception class. * @author Kingstar * @since 1.0 */ diff --git a/src/main/java/org/teasoft/bee/osql/ObjSQLIllegalSQLStringException.java b/src/main/java/org/teasoft/bee/osql/ObjSQLIllegalSQLStringException.java index 8d746f1780dd91b704fc9421cd31bf2260274271..ba6993dfaf200a5fa0ad2e15da75dae4ee1b1017 100644 --- a/src/main/java/org/teasoft/bee/osql/ObjSQLIllegalSQLStringException.java +++ b/src/main/java/org/teasoft/bee/osql/ObjSQLIllegalSQLStringException.java @@ -1,7 +1,7 @@ package org.teasoft.bee.osql; /** - * 面向对象SQL非法SQL字段串异常.Object SQL illegal SQL string exception. + * Object SQL illegal SQL string exception. * @author Kingstar * @since 1.0 */ diff --git a/src/main/java/org/teasoft/bee/osql/ObjToSQL.java b/src/main/java/org/teasoft/bee/osql/ObjToSQL.java index 7121d0a3c0665b195a7578a986306110f7772956..a682c7f98d19a6b013b774acd0ea864ee916de73 100644 --- a/src/main/java/org/teasoft/bee/osql/ObjToSQL.java +++ b/src/main/java/org/teasoft/bee/osql/ObjToSQL.java @@ -18,9 +18,7 @@ package org.teasoft.bee.osql; /** - * 对象到SQL的转换(对应Suid).Object to SQL string for Suid.
- * 根据entity对象转换成DB能识别的sql语句(包括:select,update,insert,delete), - * entity 参数不能为null.
+ * Object to SQL string for Suid.
* Object to SQL string for Suid (select,update,insert,delete), * entity must not be null. * @author Kingstar @@ -28,24 +26,47 @@ package org.teasoft.bee.osql; */ public interface ObjToSQL { + /** + * Convert to select SQL statement according to entity. + * @param entity table's entity(do not allow null). + * @return the sql string. + */ public String toSelectSQL(T entity) ; + + /** + * Convert to update SQL statement according to entity. + * @param entity table's entity(do not allow null). + * @return the sql string. + */ public String toUpdateSQL(T entity) ; + + /** + * Convert to insert SQL statement according to entity. + * @param entity table's entity(do not allow null). + * @return the sql string. + */ public String toInsertSQL(T entity) ; + + /** + * Convert to delete SQL statement according to entity. + * @param entity table's entity(do not allow null). + * @return the sql string. + */ public String toDeleteSQL(T entity) ; /** - * 根据entity和Condition转换成sql语句 - * @param entity - * @param condition + * Convert to select SQL statement according to entity and condition. + * @param entity table's entity(do not allow null). + * @param condition instance of Condition. * @return the sql string. * @since 1.6 */ public String toSelectSQL(T entity,Condition condition) ; /** - * 根据entity和Condition转换成sql语句 - * @param entity - * @param condition + * Convert to delete SQL statement according to entity and condition + * @param entity table's entity(do not allow null). + * @param condition instance of Condition. * @return the sql string. * @since 1.7.2 */ diff --git a/src/main/java/org/teasoft/bee/osql/ObjToSQLRich.java b/src/main/java/org/teasoft/bee/osql/ObjToSQLRich.java index 6adfc0f43420f9492ee8d5871281878058858752..a99a50045db5a5ecde03b4959c1877f5cadfd2c3 100644 --- a/src/main/java/org/teasoft/bee/osql/ObjToSQLRich.java +++ b/src/main/java/org/teasoft/bee/osql/ObjToSQLRich.java @@ -18,7 +18,7 @@ package org.teasoft.bee.osql; /** - * 对象到SQL的转换(对应SuidRich).Object to SQL string for SuidRich. + * Object to SQL string for SuidRich. * * @author Kingstar * @since 1.0 @@ -27,13 +27,13 @@ public interface ObjToSQLRich extends ObjToSQL { public String toSelectSQL(T entity,int size); public String toSelectSQL(T entity,int start,int size); - public String toSelectSQL(T entity,String fields); + public String toSelectSQL(T entity,String... fields); public String toSelectSQL(T entity,String selectFields,int start,int size); public String toUpdateSQL(T entity,String updateFields); public String toUpdateSQL(T entity,String updateFields,IncludeType includeType); - public String toSelectFunSQL(T entity,FunctionType functionType, String FieldForFun,Condition condition); + public String toSelectFunSQL(T entity,FunctionType functionType, String fieldForFun,Condition condition); public String toSelectOrderBySQL(T entity, String orderFields); public String toSelectOrderBySQL(T entity, String orderFields,OrderType[] orderTypes); diff --git a/src/main/java/org/teasoft/bee/osql/Op.java b/src/main/java/org/teasoft/bee/osql/Op.java index af45fac1fb0b0fc83f93df95591aacc02661b994..625cd7f119fce9ee54c3dc4ea21663ef90127766 100644 --- a/src/main/java/org/teasoft/bee/osql/Op.java +++ b/src/main/java/org/teasoft/bee/osql/Op.java @@ -1,7 +1,7 @@ package org.teasoft.bee.osql; /** - * SQL语言的各种操作符.SQL's Operation Type. + * SQL's Operation Type. * @author Kingstar * @since 1.3 */ diff --git a/src/main/java/org/teasoft/bee/osql/OrderType.java b/src/main/java/org/teasoft/bee/osql/OrderType.java index 1a1b3847af771209b1a9cae124b0419b1a742f7b..9979b8e1b4ca6b6e7801d1f8418abf67a3a1932d 100644 --- a/src/main/java/org/teasoft/bee/osql/OrderType.java +++ b/src/main/java/org/teasoft/bee/osql/OrderType.java @@ -1,19 +1,19 @@ package org.teasoft.bee.osql; /** - * SQL语言的排序类型(asc,desc).SQL's Order type(asc,desc). + * SQL's Order type(asc,desc). * @author Kingstar * @since 1.0 */ public enum OrderType { /** - * 顺序,对应SQL的asc.Corresponding to ASC of SQL + * Corresponding to ASC of SQL */ ASC("asc"), /** - * 倒序,对应SQL的desc.Corresponding to desc of SQL + * Corresponding to desc of SQL */ DESC("desc"); @@ -24,7 +24,7 @@ public enum OrderType { } /** - * 返回排序类型.return type of order. + * return type of order. * @return type of order. */ public String getName(){ diff --git a/src/main/java/org/teasoft/bee/osql/PreparedSql.java b/src/main/java/org/teasoft/bee/osql/PreparedSql.java index af5644c849353a336449971e7eac073f04552453..0ca34a7cc55af359d16d56aa8f691c281d3c51bf 100644 --- a/src/main/java/org/teasoft/bee/osql/PreparedSql.java +++ b/src/main/java/org/teasoft/bee/osql/PreparedSql.java @@ -21,352 +21,444 @@ import java.util.List; import java.util.Map; /** - * 支持带占位符的sql操作.sql语句是DB能识别的SQL,非面向对象的sql - *
Support sql string with placeholder.The sql statement is really DB's grammar,not object oriented type. - *

支持的占位符有:? 或者 #{para} 或者 #{para%}, 都可以通过PreparedStatement防范SQL注入攻击. - *
Support placeholder ? or #{para} or #{para%} - *

若是可以,建议使用面向对象的操作方式,如:Suid和SuidRich,可以使用Bee缓存,获取更高的查询效率. - *
若没有使用占位符,则传入空数组或Map即可. + * Support sql string with placeholder.The sql statement is really DB's grammar,not object oriented type. + *
Support placeholder ? or #{para} or #{para%} or #{%para} or #{%para%}, + *
can prevent SQL injection attacks through Preparedstatement *

If possible, it is recommended to use object-oriented operation methods, such as Suid and SuidRich. *
It can use Bee cache to achieve higher query efficiency. * - *
注意 Notice: - *
PreparedSql没有T参数的方法中,因没有与entity关联,在多数据源情况下,只会从默认数据源中获取数据. - *
PreparedSql method which which no T parameter, is not associated with entity, in the case of - *
multiple Datasources, will be select the record from the default Datasource. + *
Notice: + *
PreparedSql method which no T parameter, is not associated with entity, in the case of + *
multiple dataSource, will be select the record from the default dataSource. + *
from V1.11 version, can set the dataSource name. * * @author Kingstar * @since 1.0

- * 支持如name=#{name},name like #{name%}的map参数形式.

+ * Support map parameter forms such as name = #{name}, name like #{name%}

* @since 1.2 */ -public interface PreparedSql { +public interface PreparedSql extends CommOperate { /** - * 通过问号的占位语句查询数据.Select record(s) via the placeholder(?) statement. - * eg: select * from orders where userid=? - * @param sql 直接用?作为占位符的sql查询语句. - * @param returnType 返回entity的类型. - * @param preValues 按下标顺序给sql的占位符设值的Object数组. - * @return 返回returnType类型的实体List. + * Select record(s) via the placeholder(?) statement. + *
eg: select * from orders where userid=? + * @param sql SQL select statement which direct use ? as placeholder + * @param returnType its type same as list element. + * @param preValues An object array that values set for the SQL placeholders in index order. + * @return List which element type is same as returnType. */ public List select(String sql,T returnType,Object preValues[]); /** - * 通过问号的占位语句查询数据.Select record(s) via the placeholder(?) statement. - * eg: select * from orders where userid=? - * @param sql 直接用?作为占位符的sql查询语句. - * @param returnType 返回entity的类型. - * @param preValues 按下标顺序给sql的占位符设值的Object数组. - * @return 返回returnType类型的实体List. + * Select record(s) via no placeholder(?) select statement. + * @param sql SQL select statement(no placeholder). + * @param returnType its type same as list element. + * @return List which element type is same as returnType. + * @since V1.11 + */ + public List select(String sql,T returnType); + + /** + * Select record(s) via the placeholder(?) statement,paging generate by Bee. + *
eg: select * from orders where userid=? + * @param sql SQL select statement(use ? placeholder). + * @param returnType its type same as list element. + * @param preValues An object array that values set for the SQL placeholders in index order. + * @param start Start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). + * @param size Fetch result size (>0). + * @return List which element type is same as returnType. */ public List select(String sql,T returnType,Object preValues[],int start,int size); /** - * 通过变量的占位语句查询数据.entity和map都可以向参数传递值,map可以作为entity的补充,用于传递范围查询等复杂查询的参数 - *
Select the record(s) via the placeholder statement of variable.Both entity and map can pass values to parameters.
- * Map can be used as a supplement of entity to pass parameters of complex queries such as range query.

- * eg:select * from orders where userid=#{userid} - * eg:select * from orders where name like #{name%} - * @param sqlStr 使用#{para}作为占位符的sql查询语句. - * @param entity entity中非null的值,会转换成map的元素作为参数,entity的字段会自动转成表的列名;entity也将作用返回结构的类型. - * @param parameterMap map结构的参数,通过map的key与sqlStr中变量名对应. - * 若map有元素的key与从entity转来的一样,会使用map的. - * @return 返回与entity类型一样的实体List. + *
Select the record(s) via the placeholder statement of variable.Both entity and map can pass values to parameters. + *
Map can be used as a supplement of entity to pass parameters of complex queries such as range query. + *
eg:select * from orders where userid=#{userid} + *
eg:select * from orders where name like #{name%} + * @param sqlStr SQL select statement(use #{para} placeholder). + * @param entity The non null value in entity will be converted into the element of map as the parameter, + *
and the field of entity will be automatically converted into the column name of the table. + *
Entity will also act as the type of the return structure. + * @param parameterMap The parameters of map structure correspond, the variable name in sqlstr correspond the key of map. + *
If the key of the map element is the same as that transferred from the entity, the key of the map will be used. + * @return Entity List which element type is same as entity. */ public List select(String sqlStr,T entity,Map parameterMap); /** - * 通过变量的占位语句查询数据.entity和map都可以向参数传递值,map可以作为entity的补充,用于传递范围查询等复杂查询的参数 - *
Select the record(s) via the placeholder statement of variable.Both entity and map can pass values to parameters.
- * Map can be used as a supplement of entity to pass parameters of complex queries such as range query.

- * eg:select * from orders where userid=#{userid} - * eg:select * from orders where name like #{name%} - * @param sqlStr 使用#{para}作为占位符的sql查询语句. - * @param entity entity中非null的值,会转换成map的元素作为参数,entity的字段会自动转成表的列名;entity也将作用返回结构的类型. - * @param parameterMap map结构的参数,通过map的key与sqlStr中变量名对应. - * 若map有元素的key与从entity转来的一样,会使用map的. - * @param start 开始下标(从0或1开始,eg:MySQL是0,Oracle是1). start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). - * @param size 结果集大小 大于等于1. fetch result size (>0). - * @return 返回与entity类型一样的实体List. + * Select the record(s) via the placeholder statement of variable.Both entity and map can pass values to parameters. + *
Map can be used as a supplement of entity to pass parameters of complex queries such as range query. + *
paging generate by Bee + *
eg:select * from orders where userid=#{userid} + *
eg:select * from orders where name like #{name%} + * @param sqlStr SQL select statement(use #{para} placeholder). + * @param entity The non null value in entity will be converted into the element of map as the parameter, + *
and the field of entity will be automatically converted into the column name of the table. + *
Entity will also act as the type of the return structure. + * @param parameterMap The parameters of map structure correspond, the variable name in sqlstr correspond the key of map. + *
If the key of the map element is the same as that transferred from the entity, the key of the map will be used. + * @param start Start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). + * @param size Fetch result size (>0). + * @return Entity List which element type is same as entity. */ public List select(String sqlStr,T entity,Map parameterMap,int start,int size); /** - * 通过问号的占位语句查询数据(只查询部分字段) - *
Select some column of record(s) via the placeholder(?) statement.

+ * Select some column of record(s) via the placeholder(?) statement.
* eg: select * from orders where userid=? - * @param sql 直接用?作为占位符的sql查询语句. - * @param returnType 返回entity的类型. - * @param preValues 按下标顺序给sql的占位符设值的Object数组. - * @return 返回returnType类型的实体List. + * @param sql SQL select statement(use ? placeholder). + * @param returnType its type same as list element. + * @param preValues An object array that values set for the SQL placeholders in index order. + * @return List which element type is same as returnType. */ public List selectSomeField(String sql,T returnType,Object preValues[]); /** - * 通过问号的占位语句查询数据(只查询部分字段) - *
Select some column of record(s) via the placeholder(?) statement.

+ * Select some column of record(s) via the placeholder(?) statement,paging generate by Bee.

* eg: select * from orders where userid=? - * @param sql 直接用?作为占位符的sql查询语句. - * @param returnType 返回entity的类型. - * @param preValues 按下标顺序给sql的占位符设值的Object数组. - * @param start 开始下标(从0或1开始,eg:MySQL是0,Oracle是1). start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). - * @param size 结果集大小 大于等于1. fetch result size (>0). - * @return 返回returnType类型的实体List. + * @param sql SQL select statement(use ? placeholder). + * @param returnType its type same as list element. + * @param preValues An object array that values set for the SQL placeholders in index order. + * @param start Start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). + * @param size Fetch result size (>0). + * @return List which element type is same as returnType. */ public List selectSomeField(String sql,T returnType,Object preValues[],int start,int size); /** - * 通过变量的占位语句查询数据(只查询部分字段).entity和map都可以向参数传递值,map可以作为entity的补充,用于传递范围查询等复杂查询的参数 - *
Select some column of the record(s) via the placeholder statement of variable.Both entity and map can pass values to parameters.
- * Map can be used as a supplement of entity to pass parameters of complex queries such as range query.

- * eg:select * from orders where userid=#{userid} - * eg:select * from orders where name like #{name%} - * @param sqlStr 使用#{para}作为占位符的sql查询语句. - * @param entity entity中非null的值,会转换成map的元素作为参数,entity的字段会自动转成表的列名;entity也将作用返回结构的类型. - * @param parameterMap map结构的参数,通过map的key与sqlStr中变量名对应. - * 若map有元素的key与从entity转来的一样,会使用map的. - * @return 返回与entity类型一样的实体List. + * Select some column of the record(s) via the placeholder statement of variable.Both entity and map can pass values to parameters.
+ * Map can be used as a supplement of entity to pass parameters of complex queries such as range query. + *
eg:select * from orders where userid=#{userid} + *
eg:select * from orders where name like #{name%} + * @param sqlStr SQL select statement(use #{para} placeholder). + * @param entity The non null value in entity will be converted into the element of map as the parameter, + *
and the field of entity will be automatically converted into the column name of the table. + *
Entity will also act as the type of the return structure. + * @param parameterMap The parameters of map structure correspond, the variable name in sqlstr correspond the key of map. + *
If the key of the map element is the same as that transferred from the entity, the key of the map will be used. + * @return Entity List which element type is same as entity. */ public List selectSomeField(String sqlStr,T entity,Map parameterMap); /** - * 通过变量的占位语句查询数据(只查询部分字段).entity和map都可以向参数传递值,map可以作为entity的补充,用于传递范围查询等复杂查询的参数 - *
Select some column of the record(s) via the placeholder statement of variable.Both entity and map can pass values to parameters.
+ * Select some column of the record(s) via the placeholder statement of variable.Both entity and map can pass values to parameters.
* Map can be used as a supplement of entity to pass parameters of complex queries such as range query.

- * eg:select * from orders where userid=#{userid} - * eg:select * from orders where name like #{name%} - * @param sqlStr 使用#{para}作为占位符的sql查询语句. - * @param entity entity中非null的值,会转换成map的元素作为参数,entity的字段会自动转成表的列名;entity也将作用返回结构的类型. - * @param parameterMap map结构的参数,通过map的key与sqlStr中变量名对应. - * 若map有元素的key与从entity转来的一样,会使用map的. - * @param start 开始下标(从0或1开始,eg:MySQL是0,Oracle是1). start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). - * @param size 结果集大小 大于等于1. fetch result size (>0). - * @return 返回与entity类型一样的实体List. + * paging generate by Bee + *
eg:select * from orders where userid=#{userid} + *
eg:select * from orders where name like #{name%} + * @param sqlStr SQL select statement(use #{para} placeholder). + * @param entity The non null value in entity will be converted into the element of map as the parameter, + *
and the field of entity will be automatically converted into the column name of the table. + *
Entity will also act as the type of the return structure. + * @param parameterMap The parameters of map structure correspond, the variable name in sqlstr correspond the key of map. + *
If the key of the map element is the same as that transferred from the entity, the key of the map will be used. + * @param start Start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). + * @param size Fetch result size (>0). + * @return Entity List which element type is same as entity. */ public List selectSomeField(String sqlStr,T entity,Map parameterMap,int start,int size); /** - * 用函数查询结果.Select result with function. SQL function: max,min,avg,sum,count.

- * 注意:因没有与entity关联,没有应用上缓存. Notice:can not use the cache because don't relay the entity. - *
因没有与entity关联,在多数据源情况下,只会从默认数据源中获取数据. - *
Because it is not associated with entity, in the case of multiple Datasources, - *
will be select the record from the default Datasource. - * @param sql SQL select statement - * @param preValues 按下标顺序给sql的占位符设值的Object数组. - * @return 返回函数统计的值.如果统计的结果集为空,除了count返回0,其它都返回空字符. + * Select result with function. SQL function: max,min,avg,sum,count.

+ * Notice:can not use the cache because don't relay the entity. + *
Because it is not associated with entity, in the case of multiple dataSource, + *
will be select the record from the default dataSource. + * @param sql SQL select statement(use ? placeholder). + * @param preValues An object array that values set for the SQL placeholders in index order. + * @return The value of function statistics. + *
If the result set of statistics is empty,the count return 0,the other return empty string. */ public String selectFun(String sql,Object preValues[]); /** - * 用函数查询结果.Select result with function. SQL function: max,min,avg,sum,count.

- * 注意:因没有与entity关联,没有应用上缓存. Notice:can not use the cache because don't relay the entity. - *
因没有与entity关联,在多数据源情况下,只会从默认数据源中获取数据. - *
Because it is not associated with entity, in the case of multiple Datasources, - *
will be select the record from the default Datasource. + * Select result with function. SQL function: max,min,avg,sum,count.

+ * Notice:can not use the cache because don't relay the entity. + *
Because it is not associated with entity, in the case of multiple dataSource, + *
will be select the record from the default dataSource. * @param sqlStr SQL select statement - * @param map map结构的参数,通过map的key与sqlStr中变量名对应. - * @return 返回函数统计的值.如果统计的结果集为空,除了count返回0,其它都返回空字符. + * @param parameterMap The parameters of map structure correspond, the variable name in sqlStr correspond the key of map. + * @return The value of function statistics. + *
If the result set of statistics is empty,the count return 0,the other return empty string. */ - public String selectFun(String sqlStr, Map map); + public String selectFun(String sqlStr, Map parameterMap); /** - * 查询并将每一行结果转成String数组.Select and transform every record to string array.

- * 注意:因没有与entity关联,没有应用上缓存. Notice:can not use the cache because don't relay the entity. - *
因没有与entity关联,在多数据源情况下,只会从默认数据源中获取数据. - *
Because it is not associated with entity, in the case of multiple Datasources, - *
will be select the record from the default Datasource. - * @param sql SQL select statement + * Select and transform every record to string array.

+ * Notice:can not use the cache because don't relay the entity. + *
Because it is not associated with entity, in the case of multiple dataSource, + *
will be select the record from the default dataSource. + * @param sql SQL select statement(use ? placeholder). * @param preValues parameter values for placeholder - * @return 可包含多个String数组结构的多条记录的list. list can contain more than one record with String array struct. - * List, every element is string array(transform from record). + * @return List can contain more than one record with String array struct. + *
List, every element is string array(transform from record). */ public List select(String sql,Object preValues[]); /** - * 查询并将每一行结果转成String数组.Select and transform every record to string array.

- * 注意:因没有与entity关联,没有应用上缓存. Notice:can not use the cache because don't relay the entity. - *
因没有与entity关联,在多数据源情况下,只会从默认数据源中获取数据. - *
Because it is not associated with entity, in the case of multiple Datasources, - *
will be select the record from the default Datasource. - * @param sql SQL select statement + * Select and transform every record to string array. + *
Notice:can not use the cache because don't relay the entity. + *
Because it is not associated with entity, in the case of multiple dataSource, + *
will be select the record from the default dataSource. + *
paging generate by Bee. + * @param sql SQL select statement(use ? placeholder). * @param preValues parameter values for placeholder - * @param start 开始下标(从0或1开始,eg:MySQL是0,Oracle是1). start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). - * @param size 结果集大小 大于等于1. fetch result size (>0). - * @return 可包含多个String数组结构的多条记录的list. list can contain more than one record with String array struct. - * List, every element is string array(transform from record). + * @param start Start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). + * @param size Fetch result size (>0). + * @return List can contain more than one record with String array struct. + *
List, every element is string array(transform from record). */ - public List select(String sql,Object preValues[],int start,int size); + public List select(String sql, Object preValues[], int start, int size); /** - * 查询并将每一行结果转成String数组.Select and transform every record to string array.

- * 注意:因没有与entity关联,没有应用上缓存. Notice:can not use the cache because don't relay the entity. - *
因没有与entity关联,在多数据源情况下,只会从默认数据源中获取数据. - *
Because it is not associated with entity, in the case of multiple Datasources, - *
will be select the record from the default Datasource. - * @param sqlStr SQL select statement + * Select and transform every record to string array. + *
Notice:can not use the cache because don't relay the entity. + *
Because it is not associated with entity, in the case of multiple dataSource, + *
will be select the record from the default dataSource. + * @param sqlStr SQL select statement * @param map parameter values for placeholder - * @return 可包含多个String数组结构的多条记录的list. list can contain more than one record with String array struct. + * @return list can contain more than one record with String array struct. * List, every element is string array(transform from record). */ public List select(String sqlStr,Map map); /** - * 查询并将每一行结果转成String数组.Select and transform every record to string array.

- * 注意:因没有与entity关联,没有应用上缓存. Notice:can not use the cache because don't relay the entity. - *
因没有与entity关联,在多数据源情况下,只会从默认数据源中获取数据. - *
Because it is not associated with entity, in the case of multiple Datasources, - *
will be select the record from the default Datasource. - * @param sqlStr SQL select statement + * Select and transform every record to string array. + *
Notice:can not use the cache because don't relay the entity. + *
Because it is not associated with entity, in the case of multiple dataSource, + *
will be select the record from the default dataSource. + *
paging generate by Bee. + * @param sqlStr SQL select statement * @param map parameter values for placeholder - * @param start 开始下标(从0或1开始,eg:MySQL是0,Oracle是1). start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). - * @param size 结果集大小 大于等于1. fetch result size (>0). - * @return 可包含多个String数组结构的多条记录的list. list can contain more than one record with String array struct. + * @param start Start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). + * @param size Fetch result size (>0). + * @return list can contain more than one record with String array struct. * List, every element is string array(transform from record). */ public List select(String sqlStr,Map map,int start,int size); /** - * 用可带问号的占位语句查询结果,并以json格式返回.Select and return json format result.

- * 注意:因没有与entity关联,没有应用上缓存. Notice:can not use the cache because don't relay the entity. - *
因没有与entity关联,在多数据源情况下,只会从默认数据源中获取数据. - *
Because it is not associated with entity, in the case of multiple Datasources, - *
will be select the record from the default Datasource. - * @param sql SQL select statement - * @param preValues 占位符对应的参数数组.parameter values for placeholder - * @return 返回json格式结果集.json format result . + * Select and return json format result. + *
Notice:can not use the cache because don't relay the entity. + *
Because it is not associated with entity, in the case of multiple dataSource, + *
will be select the record from the default dataSource. + * @param sql SQL select statement(use ? placeholder). + * @param preValues parameter values for placeholder + * @return Json format result. */ public String selectJson(String sql,Object preValues[]); /** - * 用可带问号的占位语句查询结果,并以json格式返回.Select and return json format result.

- * 注意:因没有与entity关联,没有应用上缓存. Notice:can not use the cache because don't relay the entity. - *
因没有与entity关联,在多数据源情况下,只会从默认数据源中获取数据. - *
Because it is not associated with entity, in the case of multiple Datasources, - *
will be select the record from the default Datasource. - * @param sql SQL select statement - * @param preValues 占位符对应的参数数组.parameter values for placeholder - * @param start 开始下标(从0或1开始,eg:MySQL是0,Oracle是1). start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). - * @param size 结果集大小 大于等于1. fetch result size (>0). - * @return 返回json格式结果集.json format result . + * Select and return json format result. + *
Notice:can not use the cache because don't relay the entity. + *
Because it is not associated with entity, in the case of multiple dataSource, + *
will be select the record from the default dataSource. + *
paging generate by Bee. + * @param sql SQL select statement(use ? placeholder). + * @param preValues parameter values for placeholder + * @param start Start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). + * @param size Fetch result size (>0). + * @return Json format result. */ public String selectJson(String sql,Object preValues[],int start,int size); /** - * 查询结果,并以json格式返回.Select and return json format result.

- * 注意:因没有与entity关联,没有应用上缓存. Notice:can not use the cache because don't relay the entity. - *
因没有与entity关联,在多数据源情况下,只会从默认数据源中获取数据. - *
Because it is not associated with entity, in the case of multiple Datasources, - *
will be select the record from the default Datasource. - * @param sqlStr SQL select statement - * @param map 占位符对应的参数map.parameter values for placeholder - * @return 返回json格式结果集.json format result . + * Select and return json format result. + *
Notice:can not use the cache because don't relay the entity. + *
Because it is not associated with entity, in the case of multiple dataSource, + *
will be select the record from the default dataSource. + * @param sqlStr SQL select statement + * @param map parameter values for placeholder + * @return Json format result. */ public String selectJson(String sqlStr,Map map); /** - * 查询结果,并以json格式返回.Select and return json format result.

- * 注意:因没有与entity关联,没有应用上缓存. Notice:can not use the cache because don't relay the entity. - *
因没有与entity关联,在多数据源情况下,只会从默认数据源中获取数据. - *
Because it is not associated with entity, in the case of multiple Datasources, - *
will be select the record from the default Datasource. + * Select and return json format result. + *
Notice:can not use the cache because don't relay the entity. + *
Because it is not associated with entity, in the case of multiple dataSource, + *
will be select the record from the default dataSource. + *
paging generate by Bee. * @param sqlStr SQL select statement - * @param map 占位符对应的参数map.parameter values for placeholder - * @param start 开始下标(从0或1开始,eg:MySQL是0,Oracle是1). start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). - * @param size 结果集大小 大于等于1. fetch result size (>0). - * @return 返回json格式结果集.json format result . + * @param map parameter values for placeholder + * @param start Start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). + * @param size Fetch result size (>0). + * @return Json format result. */ public String selectJson(String sqlStr,Map map,int start,int size); - /** - * 查询结果,并以json格式返回.Select and return json format result.

- * 注意:因没有与entity关联,没有应用上缓存. Notice:can not use the cache because don't relay the entity. - *
因没有与entity关联,在多数据源情况下,只会从默认数据源中获取数据. - *
Because it is not associated with entity, in the case of multiple Datasources, - *
will be select the record from the default Datasource. - * @param sqlStr 无参数的sql查询语句.SQL select statement - * @return 返回json格式结果集.json format result . + * Select and return json format result.

+ *
Notice:can not use the cache because don't relay the entity. + *
Because it is not associated with entity, in the case of multiple dataSource, + *
will be select the record from the default dataSource. + * @param sqlStr SQL select statement(do not contain placeholder) + * @return Json format result. */ public String selectJson(String sqlStr); /** - * 通过无参数的sql查询语句数据.Select record(s) via the sql statement. - * 注意:因没有与entity关联,没有应用上缓存. Notice:can not use the cache because don't relay the entity. - *
因没有与entity关联,在多数据源情况下,只会从默认数据源中获取数据. - *
Because it is not associated with entity, in the case of multiple Datasources, - *
will be select the record from the default Datasource. + * Select record(s) via the sql statement. + *
Notice:can not use the cache because don't relay the entity. + *
Because it is not associated with entity, in the case of multiple dataSource, + *
will be select the record from the default dataSource. * eg: select * from orders where userid=10001 - * @param sql 无参数的sql查询语句.SQL select statement - * @return 返回returnType类型的实体List. + * @param sql SQL select statement(do not contain placeholder) + * @return List can contain more than one record with String array struct. + *
List, every element is string array(transform from record). */ public List select(String sql); /** - * 用函数查询结果.Select result with function. SQL function: max,min,avg,sum,count.

- * 注意:因没有与entity关联,没有应用上缓存. Notice:can not use the cache because don't relay the entity. - *
因没有与entity关联,在多数据源情况下,只会从默认数据源中获取数据. - *
Because it is not associated with entity, in the case of multiple Datasources, - *
will be select the record from the default Datasource. - * @param sql SQL select statement - * @return 返回函数统计的值.如果统计的结果集为空,除了count返回0,其它都返回空字符. + * Select result with function. SQL function: max,min,avg,sum,count.

+ * Notice:can not use the cache because don't relay the entity. + *
Because it is not associated with entity, in the case of multiple dataSource, + *
will be select the record from the default dataSource. + * @param sql SQL select statement(do not contain placeholder) + * @return The value of function statistics. + *
If the result set of statistics is empty,the count return 0,the other return empty string. */ public String selectFun(String sql); /** - * 用操作类型为update,insert,delete的语句更新数据库记录 * Modify database records with update, insert or delete statement. - * @deprecated 不建议使用,因为框架不知道具体是更改了什么表,会影响缓存的正确性,从而产生缓存数据不准确的危险.
It is not recommended because - * the framework does not know what table has been changed, which will affect the correctness of the cache and - * cause the risk of inaccurate cache data. - * @param sql SQL语句.SQL statement. - * @param preValues 占位符对应的参数数组.parameter values for placeholder - * @return 返回成功操作的记录行数. the number of successful records. + * @deprecated It is not recommended because + *
the framework does not know what table has been changed, which will affect the correctness + *
of the cache and cause the risk of inaccurate cache data. + * @param sql SQL select statement(use ? placeholder). + * @param preValues parameter values for placeholder + * @return the number of affected successfully records. */ @Deprecated public int modify(String sql,Object preValues[]); /** - * 用操作类型为update,insert,delete的语句更新数据库记录 * Modify database records with update, insert or delete statement. - * @deprecated 不建议使用,因为框架不知道具体是更改了什么表,会影响缓存的正确性,从而产生缓存数据不准确的危险.
It is not recommended because + * @deprecated It is not recommended because * the framework does not know what table has been changed, which will affect the correctness of the cache and * cause the risk of inaccurate cache data. - * @param sql SQL语句.SQL statement. - * @param map 占位符对应的参数map.parameter values for placeholder - * @return 返回成功操作的记录行数. the number of successful records. + * @param sql SQL statement. + * @param map parameter values for placeholder + * @return the number of affected successfully records. */ @Deprecated public int modify(String sql,Map map); /** - * 用操作类型为update,insert,delete的语句更新数据库记录 * Modify database records with update, insert or delete statement. - * @deprecated 不建议使用,因为框架不知道具体是更改了什么表,会影响缓存的正确性,从而产生缓存数据不准确的危险.
It is not recommended because - * the framework does not know what table has been changed, which will affect the correctness of the cache and - * cause the risk of inaccurate cache data. - * @param sql SQL语句.SQL statement. - * @return 返回成功操作的记录行数. the number of successful records. + * @deprecated It is not recommended because the framework does not know what table has been changed, + *
which will affect the correctness of the cache and cause the risk of inaccurate cache data. + * @param sql SQL statement. + * @return the number of affected successfully records. * @since 1.9 */ @Deprecated public int modify(String sql); /** - * 查询记录并返回元素为Map的List结构数据.Query records and return list structure data whose element is Map. - * @param sql SQL语句.SQL statement. - * @return List>结构的多行记录. - *
the multi-line record of List> structure. + * Query records and return list structure data whose element is Map. + * @param sql SQL statement(do not contain placeholder). + * @return the multi-line record of List> structure. */ public List> selectMapList(String sql); /** - * 查询记录并返回元素为Map的List结构数据.Query records and return list structure data whose element is Map. - * @param sql SQL语句.SQL statement. - * @param start 开始下标(从0或1开始,eg:MySQL是0,Oracle是1). start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). - * @param size 结果集大小 大于等于1. fetch result size (>0). - * @return List>结构的多行记录. - *
the multi-line record of List> structure. + * Query records and return list structure data whose element is Map. + * @param sql SQL statement. + * @return the multi-line record of List> structure. + * @since V1.11 + */ + + /** + * Query records and return list structure data whose element is Map. + * @param sqlStr SQL statement. + * @param parameterMap The parameters of map structure correspond, the variable name in sqlStr correspond the key of map. + * @return the multi-line record of List> structure. + * @since V1.11 */ - public List> selectMapList(String sql,int start,int size); + public List> selectMapList(String sqlStr,Map parameterMap); + + + /** + * Query records and return list structure data whose element is Map. + *
paging generate by Bee. + * @param sql SQL statement. + * @param parameterMap + * @param start Start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). + * @param size Fetch result size (>0). + * @return the multi-line record of List> structure. + * @since V1.11 + */ + public List> selectMapList(String sql,Map parameterMap,int start,int size); + + /** + * Select more table record(s) via no placeholder(?) select statement. + * @param sql SQL select statement(no placeholder). + * @param returnType its type same as list element. + * @return List which element type is same as returnType. + * @since V1.11 + */ + public List moreTableSelect(String sql, T returnType); + + /** + * Select the more table record(s) via the placeholder statement of variable. + *
Both entity and map can pass values to parameters. + *
Map can be used as a supplement of entity to pass parameters of complex queries such as range query. + *
eg:select * from orders where userid=#{userid} + *
eg:select * from orders where name like #{name%} + *
Only the data of the main table is parsed as a parameter. + * @param sqlStr SQL select statement(use #{para} placeholder). + * @param entity The non null value in entity will be converted into the element of map as the parameter, + *
and the field of entity will be automatically converted into the column name of the table. + *
Entity will also act as the type of the return structure. + * @param parameterMap The parameters of map structure correspond, the variable name in sqlstr correspond the key of map. + *
If the key of the map element is the same as that transferred from the entity, the key of the map will be used. + * @return Entity List which element type is same as entity. + * @since V1.11 + */ + public List moreTableSelect(String sqlStr,T entity,Map parameterMap); + + /** + * Select the more table record(s) via the placeholder statement of variable.Both entity and map can pass values to parameters. + *
Map can be used as a supplement of entity to pass parameters of complex queries such as range query. + *
paging generate by Bee + *
eg:select * from orders where userid=#{userid} + *
eg:select * from orders where name like #{name%} + *
Only the data of the main table is parsed as a parameter. + * @param sqlStr SQL select statement(use #{para} placeholder). + * @param entity The non null value in entity will be converted into the element of map as the parameter, + *
and the field of entity will be automatically converted into the column name of the table. + *
Entity will also act as the type of the return structure. + * @param parameterMap The parameters of map structure correspond, the variable name in sqlstr correspond the key of map. + *
If the key of the map element is the same as that transferred from the entity, the key of the map will be used. + * @param start Start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). + * @param size Fetch result size (>0). + * @return Entity List which element type is same as entity. + * @since V1.11 + */ + public List moreTableSelect(String sqlStr,T entity,Map parameterMap,int start,int size); + + + /** + * Insert records by batch type. + * @param sql + * @param parameterMapList every element of List is a map corresponds to one record, every field add in map struct. + * @return the number of inserted record(s) successfully;if fails, return -1. + * @since 1.11 + */ + public int insertBatch(String sql, List> parameterMapList); + + /** + * + * Insert records by batch type and batchSize. + * @param sql + * @param parameterMapList every element of List is a map corresponds to one record, every field add in map struct. + * @param batchSize + * @return the number of inserted record(s) successfully;if fails, return -1. + * @since 1.11 + */ + public int insertBatch(String sql, List> parameterMapList, int batchSize); + + //why has not List ? If you know the entity structure, use object-oriented way. +// public int insertBatch(String sql, List parameterMapList, int batchSize); + } diff --git a/src/main/java/org/teasoft/bee/osql/Properties.java b/src/main/java/org/teasoft/bee/osql/Properties.java new file mode 100644 index 0000000000000000000000000000000000000000..263d05384a519c88fbfd5f32c6ac64b70743ffde --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/Properties.java @@ -0,0 +1,31 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql; + +/** + * Properties interface. + * @author Kingstar + * @since 1.11 + */ +public interface Properties { + + public String getProp(String key); + + public String getPropText(String key); + +} diff --git a/src/main/java/org/teasoft/bee/osql/Registry.java b/src/main/java/org/teasoft/bee/osql/Registry.java new file mode 100644 index 0000000000000000000000000000000000000000..b13dbe9233a1b9444c9a0d499447bed3c3643bf9 --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/Registry.java @@ -0,0 +1,27 @@ +/* + * Copyright 2020-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql; + +/** + * Registry interface. + * @author Kingstar + * @since 1.11 + */ +public interface Registry { + +} diff --git a/src/main/java/org/teasoft/bee/osql/Serializer.java b/src/main/java/org/teasoft/bee/osql/Serializer.java new file mode 100644 index 0000000000000000000000000000000000000000..34bb320225a314bbade1dc5a5aabfb413f045067 --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/Serializer.java @@ -0,0 +1,33 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql; + +import java.io.IOException; + +/** + * Serializer. + * @author Kingstar + * @since 1.11 + */ +public interface Serializer { + + public byte[] serialize(Object obj) throws IOException; + + public Object unserialize(byte[] bytes) throws IOException; + +} diff --git a/src/main/java/org/teasoft/bee/osql/SqlKeyWord.java b/src/main/java/org/teasoft/bee/osql/SqlKeyWord.java index aeb86e5e239cb9ef762fc3a8c5a697a3e27de6c3..308ad4a3bc21ad066c9f375da9bd5fb67543d853 100644 --- a/src/main/java/org/teasoft/bee/osql/SqlKeyWord.java +++ b/src/main/java/org/teasoft/bee/osql/SqlKeyWord.java @@ -18,7 +18,7 @@ package org.teasoft.bee.osql; /** - * SQL关键字.SQL KeyWord. + * SQL KeyWord. * @author Kingstar * @since 1.8.99 */ @@ -30,6 +30,7 @@ public interface SqlKeyWord { String where(); String insert(); + String replace(); String into(); String values(); String and(); diff --git a/src/main/java/org/teasoft/bee/osql/Suid.java b/src/main/java/org/teasoft/bee/osql/Suid.java index ebc8eb4e9150dd6b43a59e6d1bd1f0ae67373950..bffd1f978f68f598e35f1a0687b104a4bf71901e 100644 --- a/src/main/java/org/teasoft/bee/osql/Suid.java +++ b/src/main/java/org/teasoft/bee/osql/Suid.java @@ -20,102 +20,85 @@ package org.teasoft.bee.osql; import java.util.List; /** - * 数据库操作接口,包括查,改,增,删 Suid (select,update,insert,delete), - * 默认不处理null和空字符串 - *
Database operation: Suid (select,update,insert,delete), + * Database operation: Suid (select,update,insert,delete), * the null and empty string are not handled by default. * @author Kingstar * Create on 2013-6-30 22:03:15 * @since 1.0 * */ -public interface Suid { +public interface Suid extends CommOperate{ /** - * 根据实体对象entity查询数据 - *
According to entity object select records from database. - * @param entity 与表对应的实体对象,且不能为空. table's entity(do not allow null).
- * entity中非null且非空字符串作为过虑条件,操作符是等号.eg:field=value.
+ * According to entity object select records from database. + * @param entity table's entity(do not allow null).
* Entity corresponding to table and can not be null.
* If the field value is not null and not empty field as filter condition,
* the operator is equal sign.eg:field=value - * @return 可包含多个实体(多条记录)的list. list which contains more than one entity. + * @return list which contains more than one entity. */ public List select(T entity); /** - * 根据实体对象entity更新数据,这个方法用于SQL的where条件的只有id属性,其它非null(且非空字符串)字段将更新到数据库(id除外) - *
According to entity object update record.This method just has id field to SQL where expression. - * @param entity 与表对应的实体对象,且不能为空;entity中id属性不能为空,作为过虑条件
- * entity中非null且非空字符串将更新到数据库(id除外).
+ * According to entity object update record.This method just has id field to SQL where expression. * table's entity(do not allow null);id is where condition,do not allow null.
* The entity corresponding to table and can not be null.
* The ID field of entity cannot be null and as filter condition.
* The not null and not empty field will update to database except ID. - * @return 成功更新的记录数,若失败则返回小于0的整数.the numbers of update records successfully, if fails,return integer less than 0. + * @return the numbers of update records successfully, if fails,return integer less than 0. * @see SuidRich#update(Object,java.lang.String) */ public int update(T entity); /** - * 根据实体对象entity插入数据.According to entity object insert record. - * @param entity 与表对应的实体对象,且不能为空. table's entity(do not allow null).
- * entity中非null且非空字符串将插入到数据库
+ * According to entity object insert record. + * @param entity table's entity(do not allow null).
* The entity corresponding to table and can not be null.
* The not null and not empty field will insert to database. - * @return 成功插入的记录数,若失败则返回小于0的整数.the numbers of insert records successfully, if fails,return integer less than 0. + * @return the numbers of insert records successfully, if fails,return integer less than 0. */ public int insert(T entity); /** - * 根据实体对象entity插入数据,并返回主键id值.According to entity object insert record and return id value. - * @param entity 与表对应的实体对象,且不能为空. table's entity(do not allow null).
- * entity中非null且非空字符串将插入到数据库
+ * According to entity object insert record and return id value. + * @param entity table's entity(do not allow null).
* The entity corresponding to table and can not be null.
* The not null and not empty field will insert to database. - * @return 若成功,返回插入记录的id值;若失败则返回小于0的数. - *
If successful, return the id value of the inserted record; if fails, return number less than 0. + * @return If successful, return the id value of the inserted record; if fails, return number less than 0. + * @since 1.9 */ public long insertAndReturnId(T entity); /** - * 根据实体对象entity删除数据.According to entity object delete record. - * @param entity 与表对应的实体对象,且不能为空. table's entity(do not allow null).
- * entity中非null且非空字符串作为过虑条件,操作符是等号.eg:field=value
+ * According to entity object delete record. + * @param entity table's entity(do not allow null).
* The entity corresponding to table and can not be null.
* If the field value is not null and not empty field as filter condition,
* the operator is equal sign.eg:field=value - * @return 成功删除的记录数,若失败则返回小于0的整数. the numbers of delete records successfully, if fails,return integer less than 0. + * @return the numbers of delete records successfully, if fails,return integer less than 0. */ public int delete(T entity); /** - * 根据实体对象和Condition查询数据.Select the records according to entity and condition.
- * 若condition没有设置IncludeType,默认过滤NULL和空字符串 - * @param entity 与表对应的实体对象,且不能为空. table's entity(do not allow null). - * @param condition entity默认有值的字段会转成field=value的形式,其它形式可通过condition指定.
- * If the field of entity is not null or empty, it will be translate to field=value.Other can define with condition. - *
若condition没有设置IncludeType,默认过滤NULL和空字符串(但condition中op,between,notBetween方法设置的字段,不受includeType的值影响.) - * @return 可包含多个实体(多条记录)的list. list which contains more than one entity. + * Select the records according to entity and condition.
+ * @param entity table's entity(do not allow null). + * @param condition If the field of entity is not null or empty, it will be translate to field=value.Other can define with condition. + * @return list which contains more than one entity. * @since 1.6 */ public List select(T entity,Condition condition); /** - * 根据实体对象和Condition删记录.Delete the records according to entity and condition.
- * 若condition没有设置IncludeType,默认过滤NULL和空字符串 - * @param entity 与表对应的实体对象,且不能为空. table's entity(do not allow null). - * @param condition entity默认有值的字段会转成field=value的形式,其它形式可通过condition指定.
- * If the field of entity is not null or empty, it will be translate to field=value.Other can define with condition. - *
若condition没有设置IncludeType,默认过滤NULL和空字符串(但condition中op,between,notBetween方法设置的字段,不受includeType的值影响.) - * @return 成功删除的记录行数,若失败则返回小于0的整数. the number of deleted record(s) successfully, if fails,return integer less than 0. + * Delete the records according to entity and condition.
+ * @param entity table's entity(do not allow null). + * @param condition If the field of entity is not null or empty, it will be translate to field=value.Other can define with condition. + * @return the number of deleted record(s) successfully, if fails,return integer less than 0. * @since 1.7.2 */ public int delete(T entity,Condition condition); /** - * 为动态表名、实体名参数设置值.set dynamic parameter for dynamic table & entity name - *
本方法的调用要早于select,update,insert,delete等方法. + * set dynamic parameter for dynamic table & entity name *
This method is called earlier than the select, update, insert, delete methods. * @param para parameter name * @param value parameter value @@ -125,13 +108,13 @@ public interface Suid { public Suid setDynamicParameter(String para,String value); /** - * 声明开始使用同一Connection.declare begin Same Connection for some ORM operation. + * declare begin Same Connection for some ORM operation. * @since 1.9 */ public void beginSameConnection(); /** - * 声明结束使用同一Connection.declare end Same Connection for some ORM operation. + * declare end Same Connection for some ORM operation. * @since 1.9 */ public void endSameConnection(); diff --git a/src/main/java/org/teasoft/bee/osql/SuidRich.java b/src/main/java/org/teasoft/bee/osql/SuidRich.java index 4325dfdc617e6ea148de9acff9ba20acc3f651e2..6200d18ba7293ffeb3cc7cf83cdf5ba1cc98bced 100644 --- a/src/main/java/org/teasoft/bee/osql/SuidRich.java +++ b/src/main/java/org/teasoft/bee/osql/SuidRich.java @@ -20,24 +20,34 @@ package org.teasoft.bee.osql; import java.util.List; /** - * 数据库操作接口,包括查,改,增,删 Suid (select,update,insert,delete), - * 该接口比Suid接口提供更多的参数选择 - *
Database operation: Suid (select,update,insert,delete), + * Database operation: Suid (select,update,insert,delete), * it supports more parameters than Suid. * *
- * SQL UPDATE语句包括两大部分SET和WHERE,SuidRich采取指定其中一样,另一样尽量采用默认的实现方式.所以有关更新的方法分为两部分: - *
update和updateBy. - *
update方法中,String updateFields参数(若有),可以指明要更新的字段,其余字段则有可能转为SQL UPDATE语句的WHERE部分(默认过 - *
滤NULL和空字符串,可通过IncludeType显示设置). + *
The SQL UPDATE statement consists of two parts: set and where. SuidRich specifies one of them + *
and tries to use the default implementation method for the other. + *
Therefore, the update method is divided into two parts: + *
update and updateBy. + *
In the update method, the string updateFields parameter (if has) can indicate the fields to be updated, + *
and other fields may be converted to the where part of the SQL UPDATE statement (by default) + *
Filter null and empty strings, which can be explicitly set through IncludeType) * - *
updateBy方法中,String whereFields(若有),可以指明用于SQL中WHERE的字段.当指定了whereFields, 没在whereFields的字段,将默认 - *
转换为SQL UPDATE语句的SET部分(默认过滤NULL和空字符串,可通过IncludeType显示设置). - *
同一个实体的某个属性的值,若用于WHERE部分了,再用于UPDATE SET部分就没有意义(因为此时它们的值是一样的),但可以用Condition的 - *
set(String fieldName, Number num)等方法设置;Condition的方法set,setMultiply,setAdd,setWithField,是在处理WHERE字段前 - *
已完成处理的,所以不受指定的WHERE条件字段的影响. + *
in the updateBy method, string whereFields (if has) can indicate the field used for WHERE in SQL. + *
When whereFields is specified, fields that are not in whereFields will default. + *
Convert to the set part of SQL UPDATE statement (null and empty strings are filtered by default, + *
which can be explicitly set through IncludeType). + *
If the value of an attribute of the same entity is used in the where part, it is meaningless to use it + *
in the update set part (because their values are the same at this time) + *
However, it can be set by using the set(String fieldName, Number num) and other methods; + *
The method set,setMultiply,setAdd,setWithField of condition is processed before processing the where field, + *
so it is not affected by the specified where condition field * - *
update和updateBy方法的Condition设置的字段都会被解析,不受IncludeType的限制,也不受updateFields参数和whereFields参数的影响. + *
About the parameter IncludeType: + *
If IncludeType is not set in condition, null and empty strings are filtered by default (but the fields set in op, between and notBetween methods in condition are not affected by the value of includeType.) + *
If the field of entity is not null or empty, it will be translate to field=value.Other can define with condition. + * + *
The fields set by the Condition of the update and updateBy methods will be parsed, which is not limited by the + *
IncludeType, nor affected by the updateFields parameter and the whereFields parameter. * * @author Kingstar * Create on 2013-6-30 22:06:18 @@ -46,537 +56,508 @@ import java.util.List; public interface SuidRich extends Suid { /** - * 根据实体对象entity查询数据,且可以分页 - *
Select record(s) according to entity object,and can specify page information. - * @param entity 实体类对象,且不能为空. table's entity(do not allow null). - * entity中非null且非空字符串作为过虑条件,操作符是等号.eg:field=value.
- * entity corresponding to table and can not be null.
- * If the field value is not null and not empty field as filter condition,
- * the operator is equal sign.eg:field=value
- * @param size 结果集大小 大于等于1. fetch result size (>0). - * @return 可包含多个实体(多条记录)的list. list which contains more than one entity. + * Select record(s) according to entity object,and can specify page information. + * @param entity table's entity(do not allow null). + *
entity corresponding to table and can not be null. + *
If the field value is not null and not empty field as filter condition, + *
the operator is equal sign.eg:field=value
+ * @param size fetch result size (>0). + * @return list which contains more than one entity. */ public List select(T entity,int size); /** - * 根据实体对象entity查询数据,且可以分页 - *
Select record(s) according to entity object,and can specify page information. - * @param entity 实体类对象,且不能为空. table's entity(do not allow null). - * entity中非null且非空字符串作为过虑条件,操作符是等号.eg:field=value.
- * entity corresponding to table and can not be null.
- * If the field value is not null and not empty field as filter condition,
- * the operator is equal sign.eg:field=value - * @param start 开始下标(从0或1开始,eg:MySQL是0,Oracle是1). - *
start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). - * @param size 结果集大小 大于等于1. fetch result size (>0). - * @return 可包含多个实体(多条记录)的list. list can contain more than one entity + * Select record(s) according to entity object,and can specify page information. + * @param entity table's entity(do not allow null). + *
entity corresponding to table and can not be null. + *
If the field value is not null and not empty field as filter condition, + *
the operator is equal sign.eg:field=value + * @param start start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). + * @param size fetch result size (>0). + * @return list can contain more than one entity */ public List select(T entity,int start,int size); /** - * 查询实体时,只查询部分一部分字段.Just select some fields. - * @param entity 实体类对象,且不能为空.table's entity(do not allow null). - * @param selectFields 需要查询的字段,多个用逗号隔开. select fields,if more than one,separate with comma. - * @return 可包含多个实体(多条记录)的list. list which contains more than one entity. + * Just select some fields. + * @param entity table's entity(do not allow null). + * @param selectFields select fields,if more than one,separate with comma. + * @return list which contains more than one entity. */ public List select(T entity,String selectFields); /** - * 查询实体时,只查询部分一部分字段,且可以分页 - *
Just select some fields,and can specify page information. - * @param entity 实体类对象,且不能为空.table's entity(do not allow null). - * @param selectFields 需要查询的字段,多个用逗号隔开. select fields,if more than one,separate with comma. - * @param start 开始下标(从0或1开始,eg:MySQL是0,Oracle是1). - *
start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). - * @param size 结果集大小 大于等于1. fetch result size (>0). - * @return 可包含多个实体(多条记录)的list. list which contains more than one entity. + * Just select some fields,and can specify page information. + * @param entity table's entity(do not allow null). + * @param selectFields select fields,if more than one,separate with comma. + * @param start start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). + * @param size fetch result size (>0). + * @return list which contains more than one entity. * @since 1.4.3 */ public List select(T entity,String selectFields,int start,int size); /** - * 查询实体,每个字段都是以字符串类型返回 - *
Select entity,every field will return the string type. - * @param entity 实体类对象,且不能为空.table's entity(do not allow null). - * @return 可包含多个String数组结构的多条记录的list. list can contain more than one record with String array struct. + * Select entity,every field will return the string type. + * @param entity table's entity(do not allow null). + * @return list can contain more than one record with String array struct. */ public List selectString(T entity); /** - * 查询部分字段,每个字段都是以字符串类型返回 - *
Select some field, every field will return the string type. - * @param entity 实体类对象,且不能为空.table's entity(do not allow null). - * @param selectFields 需要查询的字段,多个用逗号隔开. Select fields,if more than one,separate with comma. - * @return 可包含多个String数组结构的多条记录的list. list can contain more than one record with String array struct. + * Select some field, every field will return the string type. + * @param entity table's entity(do not allow null). + * @param selectFields Select fields,if more than one,separate with comma. + * @return list can contain more than one record with String array struct. */ - public List selectString(T entity,String selectFields); - + public List selectString(T entity,String... selectFields); /** - * 不以具体实体结构返回数据,而是用字符数组的List - *
Instead of returning data in a entity structure, it uses a character array in List. - * @param entity 实体类对象,且不能为空.table's entity(do not allow null). - * @param condition condition.若condition没有设置IncludeType,默认过滤NULL和空字符串(但condition中op,between,notBetween方法设置的字段,不受includeType的值影响.) - * @return 可包含多个String数组结构的多条记录的list. list can contain more than one record with String array struct. + * Instead of returning data in a entity structure, it uses a character array in List. + * @param entity table's entity(do not allow null). + * @param condition Condition as filter the record. + * @return list can contain more than one record with String array struct. * @since 1.9 */ public List selectString(T entity,Condition condition); /** - * 根据实体对象entity查询数据,并返回Json格式结果 - *
Select and return data in Json format according to entity object. - * @param entity 与表对应的实体对象,且不能为空.table's entity(do not allow null). - * entity中非null与非空字符串作为过虑条件,操作符是等号.eg:field=value - * @return 可包含多个实体(多条记录)的list转换成的json格式的字符串. - *
Json string, it transform from list which can contain more than one entity. + * Select and return data in Json format according to entity object. + * @param entity table's entity(do not allow null). + *
entity corresponding to table and can not be null. + *
If the field value is not null and not empty field as filter condition, + *
the operator is equal sign.eg:field=value + * @return Json string, it transform from list which can contain more than one entity. * @since 1.1 */ public String selectJson(T entity); /** - * 查询一个实体.Select one record. - * @param entity 实体类对象.table's entity(do not allow null). - * @return 只返回一个实体,数量不为1时返回null.return one record,if the size do not equal one, return null. + * Select one record. + * @param entity table's entity(do not allow null). + * @return return one record,if the size do not equal one, return null. */ public T selectOne(T entity); /** - * 使用函数查询一个统计结果.Select result with one function,Just select one function. - * @param entity 传入的实体对象,且不能为空.table's entity(do not allow null). + * Select result with one function,Just select one function. + * @param entity table's entity(do not allow null). * @param functionType MAX,MIN,SUM,AVG,COUNT - * @param fieldForFun 需要使用函数的字段.field for function. - * @return 一个函数查询的结果.one function result. + * @param fieldForFun field for function. + * @return one function result. */ public String selectWithFun(T entity, FunctionType functionType, String fieldForFun); /** - * 使用函数查询一个统计结果,通过Condition可添加复杂过滤条件(一次只查询一个统计结果) * Select result with one function,just select one function at a time. - * @param entity 传入的实体对象,且不能为空.table's entity(do not allow null). + * @param entity table's entity(do not allow null). * @param functionType MAX,MIN,SUM,AVG,COUNT - * @param fieldForFun 需要使用函数的字段.field for function. - * @param condition condition.若condition没有设置IncludeType,默认过滤NULL和空字符串(但condition中op,between,notBetween方法设置的字段,不受includeType的值影响.) - *
在此,condition的selectFun方法将被忽略.here will ignore the condition's selectFun method. - * @return 一个函数查询的结果.one function result. + * @param fieldForFun field for function. + * @param condition Condition as filter the record. + *
here will ignore the condition's selectFun method. + * @return one function result. * @since 1.9 */ public String selectWithFun(T entity, FunctionType functionType, String fieldForFun, Condition condition); //selectOneFun /** - * 统计记录总数.total number of statistical records. - * @param entity 实体类对象,且不能为空. table's entity(do not allow null). - * @return 统计记录行数. total number of records that satisfy the condition. + * total number of statistical records. + * @param entity table's entity(do not allow null). + * @return total number of records that satisfy the condition. * @since 1.9 */ public int count(T entity); /** - * 统计记录总数.total number of statistical records. - * @param entity 实体类对象,且不能为空. table's entity(do not allow null). - * @param condition condition用于设置过滤条件.condition as filter the record. - * @return 统计记录行数. total number of records that satisfy the condition. + * total number of statistical records. + * @param entity table's entity(do not allow null). + * @param condition Condition as filter the record. + * @return total number of records that satisfy the condition. * @since 1.9 */ public int count(T entity, Condition condition); /** - * 查询应用排序的结果,排序的字段默认按升序排列 * Select result with order,order type default is:asc - * @param entity 传入的实体对象,且不能为空.table's entity(do not allow null). - * @param orderFields 排序字段列表,多个用逗号隔开 - * @return 可包含多个有排序的实体(多条记录)的list. list which contains more than one entity. + * @param entity table's entity(do not allow null). + * @param orderFields order fields,if more than one,separate with comma. + * @return list which contains more than one entity. */ public List selectOrderBy(T entity,String orderFields); /** - * 查询应用排序的结果 * Select result with order. - * @param entity 传入的实体对象,且不能为空.table's entity(do not allow null). - * @param orderFields 排序字段列表,多个用逗号隔开.order fields,if more than one,separate with comma. - * @param orderTypes 排序类型列表 - * @return 可包含多个有排序的实体(多条记录)的list. list which contains more than one entity. + * @param entity table's entity(do not allow null). + * @param orderFields order fields,if more than one,separate with comma. + * @param orderTypes Sort type list. + * @return list which contains more than one entity. */ public List selectOrderBy(T entity,String orderFields,OrderType[] orderTypes); /** - * 更新记录,且可以指定需要更新的字段.Update record, can list update fields. - * @param entity 实体类对象,不能为空.table's entity(do not allow null). - * @param updateFields 需要更新的字段列表,多个字段用逗号隔开(列表中有的字段都会更新),该属性不允许为空, - *
除了updateFields中声明要更新的字段,其它非空,非null的字段作为过滤条件,转成SQL的where表达式. + * Update record, can list update fields. + * @param entity table's entity(do not allow null). + * @param updateFields update fields. *
For the list of fields to be updated, multiple fields are separated by commas (those fields will be updated). - *
This attribute cannot be empty. By default, each field will be converted to a set expression of SQL update. - * @return 成功更新的记录数,若失败则返回小于0的整数.the numbers of update record(s) successfully,if fails, return integer less than 0. + *
This attribute cannot be empty and is not affected by the includeType parameter; By default, each field will be + *
converted to a set expression of SQL update. + * @return the numbers of update record(s) successfully,if fails, return integer less than 0. */ public int update(T entity,String updateFields); /** - * 根据实体对象entity更新数据,可以指定需要更新的字段.Update record according to entity. - * @param entity 与表对应的实体对象,且不能为空.table's entity(do not allow null). - * id为null不作为过滤条件 - * @param updateFields 需要更新的字段列表,多个字段用逗号隔开(列表中有的字段都会更新),该属性不允许为空,且不受includeType参数的影响,默认每个字段会被转化成SQL update的set表达式 + * Update record according to entity. + * @param entity table's entity(do not allow null).if id's value is null can not as filter condition. + * @param updateFields update fields. *
For the list of fields to be updated, multiple fields are separated by commas (those fields will be updated). - *
This attribute cannot be empty and is not affected by the includeType parameter. By default, each field will be + *
This attribute cannot be empty and is not affected by the includeType parameter; By default, each field will be *
converted to a set expression of SQL update. - * @param includeType 空字符串与null是否作为过滤条件.whether null string and null as a filter conditions. - * @return 成功更新的记录数,若失败则返回小于0的整数.the numbers of update record(s) successfully,if fails, return integer less than 0. + * @param includeType whether null string and null as a filter conditions. + * @return the numbers of update record(s) successfully,if fails, return integer less than 0. */ public int update(T entity,String updateFields,IncludeType includeType); /** - * 批量插入数据.Insert records by batch type. - * @param entity 与表对应的实体对象数组,且不能为空. table's entity array(do not allow null). - * @return 成功插入的记录行数;失败时返回-1. the number of inserted record(s) successfully;if fails, return -1. + * Insert records by batch type. + * @param entity table's entity array(do not allow null). + * @return the number of inserted record(s) successfully;if fails, return -1. */ public int insert(T[] entity); /** - * 批量插入数据.Insert records by batch type. - * @param entity 与表对应的实体对象,且不能为空. table's entity array(do not allow null). - * @param batchSize 批操作数量大小.batch size. - * @return 成功插入的记录行数;失败时返回-1. the number of inserted record(s) successfully;if fails, return -1. + * Insert records by batch type. + * @param entity table's entity array(do not allow null). + * @param batchSize batch size. + * @return the number of inserted record(s) successfully;if fails, return -1. */ public int insert(T[] entity,int batchSize); /** - * 批量插入数据,且可以声明不用插入的字段列表 - *
Insert record by batch type,and can point out which field(s) don't need to insert. - * @param entity 与表对应的实体对象数组,且不能为空. table's entity array(do not allow null). - * @param excludeFields 声明不用插入的字段列表.fields list that don't need to insert . - * @return 成功插入的记录行数;失败时返回-1. the number of inserted record(s) successfully;if fails, return -1. + * Insert record by batch type,and can point out which field(s) don't need to insert. + * @param entity table's entity array(do not allow null). + * @param excludeFields fields list that don't need to insert . + * @return the number of inserted record(s) successfully;if fails, return -1. */ public int insert(T[] entity,String excludeFields); /** - * 批量插入数据,且可以指定不用插入的字段列表 - *
Insert record by batch type,and can point out which field(s) don't need to insert. - * @param entity 与表对应的实体对象数组,且不能为空. table's entity array(do not allow null). - * @param batchSize 批操作数量大小.batch size. - * @param excludeFields 声明不用插入的字段列表.Don't insert fields list. - * @return 成功插入的记录行数;失败时返回-1. the number of inserted record(s) successfully;if fails, return -1. + * Insert record by batch type,and can point out which field(s) don't need to insert. + * @param entity table's entity array(do not allow null). + * @param batchSize batch size. + * @param excludeFields Don't insert fields list. + * @return the number of inserted record(s) successfully;if fails, return -1. */ public int insert(T[] entity,int batchSize,String excludeFields); /** - * 批量插入数据.Insert records by batch type. - * @param entityList 与表对应的实体对象链表,且不能为空. table's entity list(do not allow null). - * @return 成功插入的记录行数;失败时返回-1. the number of inserted record(s) successfully;if fails, return -1. + * Insert records by batch type. + * @param entityList table's entity list(do not allow null). + * @return the number of inserted record(s) successfully;if fails, return -1. * @since 1.9 */ public int insert(List entityList); /** - * 批量插入数据.Insert records by batch type. - * @param entityList 与表对应的实体对象链表,且不能为空. table's entity list(do not allow null). - * @param batchSize 批操作数量大小.batch size. - * @return 成功插入的记录行数;失败时返回-1. the number of inserted record(s) successfully;if fails, return -1. + * Insert records by batch type. + * @param entityList table's entity list(do not allow null). + * @param batchSize batch size. + * @return the number of inserted record(s) successfully;if fails, return -1. * @since 1.9 */ public int insert(List entityList,int batchSize); /** - * 批量插入数据,且可以声明不用插入的字段列表 - *
Insert record by batch type,and can point out which field(s) don't need to insert. - * @param entityList 与表对应的实体对象链表,且不能为空. table's entity list(do not allow null). - * @param excludeFields 声明不用插入的字段列表.fields list that don't need to insert . - * @return 成功插入的记录行数;失败时返回-1. the number of inserted record(s) successfully;if fails, return -1. + * Insert record by batch type,and can point out which field(s) don't need to insert. + * @param entityList table's entity list(do not allow null). + * @param excludeFields fields list that don't need to insert. + * @return the number of inserted record(s) successfully;if fails, return -1. * @since 1.9 */ public int insert(List entityList,String excludeFields); /** - * 批量插入数据,且可以指定不用插入的字段列表 - *
Insert record by batch type,and can point out which field(s) don't need to insert. - * @param entityList 与表对应的实体对象链表,且不能为空. table's entity list(do not allow null). - * @param batchSize 批操作数量大小.batch size. - * @param excludeFields 声明不用插入的字段列表.Don't insert fields list. - * @return 成功插入的记录行数;失败时返回-1. the number of inserted record(s) successfully;if fails, return -1. + * Insert record by batch type,and can point out which field(s) don't need to insert. + * @param entityList table's entity list(do not allow null). + * @param batchSize batch size. + * @param excludeFields Don't insert fields list. + * @return the number of inserted record(s) successfully;if fails, return -1. * @since 1.9 */ public int insert(List entityList,int batchSize,String excludeFields); /** - * 根据实体对象entity查询数据.Select record according to entity. - * @param entity 实体类对象,且不能为空. table's entity(do not allow null). - * entity中非null且非空字符串作为过虑条件,操作符是等号.eg:field=value.
- * entity corresponding to table and can not be null.
- * If the field value is not null and not empty field as filter condition,
- * the operator is equal sign.eg:field=value
- * @param includeType 空字符串与null是否包含设置 - * @return 可包含多个实体(多条记录)的list. list which contains more than one entity. + * Select record according to entity. + * @param entity table's entity(do not allow null). + *
entity corresponding to table and can not be null. + *
If the field value is not null and not empty field as filter condition, + *
the operator is equal sign.eg:field=value + * @param includeType whether null string and null as a filter conditions. + * @return list which contains more than one entity. */ public List select(T entity,IncludeType includeType); /** - * 根据实体对象entity中id更新该实体对象的数据.Update record according to entity. - * @param entity 与表对应的实体对象,且不能为空;entity中id字段不能为空,作为过虑条件.id为null将引发ObjSQLException. - *
table's entity(do not allow null),The id field in entity cannot be empty as a filtering condition. - * @param includeType 空字符串与null是否包含设置 - * @return 成功更新的记录数,若失败则返回小于0的整数.the numbers of update record(s) successfully,if fails, return integer less than 0. + * Update record according to entity by primary key. + * @param entity table's entity(do not allow null),The id field in entity cannot be empty as a filtering condition. + * @param includeType whether null string and null as a filter conditions. + * @return the numbers of update record(s) successfully,if fails, return integer less than 0. */ public int update(T entity,IncludeType includeType); /** - * 根据实体对象entity插入数据.Insert record according to entity. - * @param entity 与表对应的实体对象,且不能为空.table's entity(do not allow null). - * @param includeType 空字符串与null是否包含设置 - * @return 成功插入的记录行数,若失败则返回小于0的整数. the number of inserted record(s) successfully,if fails, return integer less than 0. + * Insert record according to entity. + * @param entity table's entity(do not allow null). + * @param includeType whether null string and null as a filter conditions. + * @return the number of inserted record(s) successfully,if fails, return integer less than 0. */ public int insert(T entity,IncludeType includeType); /** - * 根据实体对象entity删除数据.Delete record according to entity. - * @param entity 与表对应的实体对象,且不能为空,id为null不作为过滤条件.table's entity(do not allow null). - * - * @param includeType 空字符串与null是否包含设置 - * @return 成功删除的记录行数,若失败则返回小于0的整数. the number of deleted record(s) successfully,if fails, return integer less than 0. + * According to entity object insert record and return id value. + * @param entity table's entity(do not allow null). + *
The entity corresponding to table and can not be null. + *
The not null and not empty field will insert to database. + * @param includeType whether null string and null as a filter conditions. + * @return If successful, return the id value of the inserted record; if fails, return number less than 0. + * @since V1.11 + */ + public long insertAndReturnId(T entity,IncludeType includeType); + + /** + * Delete record according to entity. + * @param entity table's entity(do not allow null). + * @param includeType whether null string and null as a filter conditions. + * @return the number of deleted record(s) successfully,if fails, return integer less than 0. */ public int delete(T entity,IncludeType includeType); /** - * 根据实体对象entity查询并返回Json格式的数据 - *
Select and return data in Json format according to entity object. - * @param entity 与表对应的实体对象,且不能为空,id为null不作为过滤条件.table's entity(do not allow null). - * @param includeType 空字符串与null是否包含设置 - * @return 可包含多个实体(多条记录)的list转换成的json格式的字符串.
Json string, it transform from list which can contain more than one entity. + * Select and return data in Json format according to entity object. + * @param entity table's entity(do not allow null). + * @param includeType whether null string and null as a filter conditions. + * @return Json string, it transform from list which can contain more than one entity. * @since 1.1 */ public String selectJson(T entity,IncludeType includeType); /** - * 查询实体时,只查询部分一部分字段,并返回Json字符串.Just select some fields,and return Json string. - * @param entity 实体类对象,且不能为空.table's entity(do not allow null). - * @param selectFields 需要查询的字段,多个用逗号隔开. select fields,if more than one,separate with comma. - * @return 包含多个实体的部分字段的Json字符串 + * Just select some fields,and return Json string. + * @param entity table's entity(do not allow null). + * @param selectFields select fields,if more than one,separate with comma. + * @return Json string, it transform from list which can contain more than one entity. * @since 1.9.8 */ public String selectJson(T entity, String selectFields); /** - * 只查询部分一部分字段,且可以分页 ,并返回Json字符串 - *
Just select some fields,and can specify page information. - * @param entity 实体类对象,且不能为空.table's entity(do not allow null). - * @param selectFields 需要查询的字段,多个用逗号隔开. select fields,if more than one,separate with comma. - * @param start 开始下标(从0或1开始,eg:MySQL是0,Oracle是1). - *
start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). - * @param size 结果集大小 大于等于1. fetch result size (>0). - * @return 包含多个实体的部分字段的Json字符串 + * Just select some fields,and can specify page information. + * @param entity table's entity(do not allow null). + * @param selectFields select fields,if more than one,separate with comma. + * @param start start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). + * @param size fetch result size (>0). + * @return Json string, it transform from list which can contain more than one entity. * @since 1.9.8 */ public String selectJson(T entity, String selectFields, int start, int size); /** - * 根据id查询记录.Select record by id. - * @param returnType 实体类对象,且不能为空.table's entity(do not allow null). - * @param id 实体id字段的值.value of entity's id field. - * @return 返回id对应的实体.return one entity which owns this id. + * Select record by id. + * @param returnType table's entity(do not allow null). + * @param id value of entity's id field. + * @return return one entity which owns this id. * @since 1.9 */ public T selectById(T returnType,Integer id); /** - * 根据id查询记录.Select record by id. - * @param returnType 实体类对象,且不能为空.table's entity(do not allow null). - *
returnType的属性值,不会被解析.The property value of returnType will not be parsed. - * @param id 实体id字段的值.value of entity's id field. - * @return 返回id对应的实体.return one entity which owns this id. + * Select record by id. + * @param returnType table's entity(do not allow null). + *
The property value of returnType will not be parsed. + * @param id value of entity's id field. + * @return return one entity which owns this id. * @since 1.9 */ public T selectById(T returnType,Long id); /** - * 根据id查询记录.Select record by id. - * @param returnType 实体类对象,且不能为空.table's entity(do not allow null). - *
returnType的属性值,不会被解析.The property value of returnType will not be parsed. - * @param id 实体id字段的值.value of entity's id field. - * @return 返回id对应的实体.return one entity which owns this id. + * Select record by id. + * @param returnType table's entity(do not allow null). + *
The property value of returnType will not be parsed. + * @param id value of entity's id field. + * @return return one entity which owns this id. * @since 1.9 */ public T selectById(T returnType,String id); /** - * 根据id查询记录.Select record by id. - * @param returnType 实体类对象,且不能为空.table's entity(do not allow null). - *
entity的属性值,不会被解析.The property value of returnType will not be parsed. - * @param ids 实体id字段的值,多个用逗号隔开.values of entity's id field,if more than one,separate with comma. - * @return 可包含多个实体(多条记录)的list. list which contains more than one entity. + * Select record by id. + * @param returnType table's entity(do not allow null). + *
The property value of returnType will not be parsed. + * @param ids values of entity's id field,if more than one,separate with comma. + * @return list which contains more than one entity. * @since 1.9 */ public List selectByIds(T returnType,String ids); /** - * 根据id删除记录.Delete record by id. - * @param c 实体类类型,且不能为空 - * @param id 实体id字段的值. value of entity's id field. - * @return 成功删除的记录行数,若失败则返回小于0的整数. the number of deleted record(s) successfully,if fails, return integer less than 0. + * Delete record by id. + * @param c table's entity class(do not allow null). + * @param id value of entity's id field. + * @return the number of deleted record(s) successfully,if fails, return integer less than 0. * @since 1.4 */ public int deleteById(Class c,Integer id); /** - * 根据id删除记录.Delete record by id. - * @param c 实体类类型,且不能为空 - * @param id 实体id字段的值. value of entity's id field. - * @return 成功删除的记录行数,若失败则返回小于0的整数. the number of deleted record(s) successfully,if fails, return integer less than 0. + * Delete record by id. + * @param c table's entity class(do not allow null). + * @param id value of entity's id field. + * @return the number of deleted record(s) successfully,if fails, return integer less than 0. * @since 1.4 */ public int deleteById(Class c,Long id); /** - * 根据id删除记录.Delete record by id. - * @param c 实体类类型,且不能为空 - * @param ids 实体id字段的值,多个用逗号隔开.ids values of entity's id field,if more than one,separate with comma. - * @return 成功删除的记录行数,若失败则返回小于0的整数. the number of deleted record(s) successfully,if fails, return integer less than 0. + * Delete record by id. + * @param c table's entity class(do not allow null). + * @param ids ids values of entity's id field,if more than one,separate with comma. + * @return the number of deleted record(s) successfully,if fails, return integer less than 0. * @since 1.4 */ public int deleteById(Class c,String ids); /** - * 根据实体对象entity查询数据.Select record according to entity. - * @deprecated {@link Suid#select(Object,Condition)}方法中,可以通过condition设置includeType.can set includeType via condition. - * @param entity 与表对应的实体对象,且不能为空,id为null不作为过滤条件.table's entity(do not allow null). - * @param includeType 空字符串与null是否包含设置 - * @param condition entity默认有值的字段会转成field=value的形式,其它形式可通过condition指定.
- * If the field of entity is not null or empty, it will be translate to field=value.Other can define with condition.
- * 若condition没有设置IncludeType,默认过滤NULL和空字符串(但condition中op,between,notBetween方法设置的字段,不受includeType的值影响.) - * @return 可包含多个实体(多条记录)的list. list which contains more than one entity. + * Select record according to entity. + * @deprecated {@link Suid#select(Object,Condition)} can set includeType via condition. + * @param entity table's entity(do not allow null).if id's value is null can not as filter condition. + * @param includeType whether null string and null as a filter conditions. + * @param condition Condition as filter the record. + * @return list which contains more than one entity. * @since 1.6 */ @Deprecated public List select(T entity,IncludeType includeType,Condition condition); /** - * 根据实体对象entity查询数据,并以Json格式返回 - *
Select and return data in Json format according to entity object. - * @deprecated {@link SuidRich#selectJson(Object,Condition)}方法中,可以通过condition设置includeType.can set includeType via condition. - * @param entity 与表对应的实体对象,且不能为空,id为null不作为过滤条件.table's entity(do not allow null). - * @param includeType 空字符串与null是否包含设置 - * @param condition entity默认有值的字段会转成field=value的形式,其它形式可通过condition指定.
- * If the field of entity is not null or empty, it will be translate to field=value.Other can define with condition.
- * 若condition没有设置IncludeType,默认过滤NULL和空字符串(但condition中op,between,notBetween方法设置的字段,不受includeType的值影响.) - * @return 可包含多个实体(多条记录)的list转换成的json格式的字符串. - *
Json string, it transform from list which can contain more than one entity. + * Select and return data in Json format according to entity object. + * @deprecated {@link SuidRich#selectJson(Object,Condition)} can set includeType via condition. + * @param entity table's entity(do not allow null).if id's value is null can not as filter condition. + * @param includeType whether null string and null as a filter conditions. + * @param condition Condition as filter the record. + * @return Json string, it transform from list which can contain more than one entity. * @since 1.6 */ @Deprecated public String selectJson(T entity,IncludeType includeType,Condition condition); /** - * 根据实体对象entity查询数据,并以Json格式返回 - *
Select and return data in Json format according to entity object. - * @param entity 与表对应的实体对象,且不能为空, id为null不作为过滤条件.table's entity(do not allow null). - * @param condition entity默认有值的字段会转成field=value的形式,其它形式可通过condition指定.
- * If the field of entity is not null or empty, it will be translate to field=value.Other can define with condition.
- * 若condition没有设置IncludeType,默认过滤NULL和空字符串(但condition中op,between,notBetween方法设置的字段,不受includeType的值影响.) - * @return 可包含多个实体(多条记录)的list转换成的json格式的字符串. - *
Json string, it transform from list which can contain more than one entity. + * Select and return data in Json format according to entity object. + * @param entity table's entity(do not allow null). + * @param condition Condition as filter the record. + * @return Json string, it transform from list which can contain more than one entity. * @since 1.9 */ public String selectJson(T entity,Condition condition); /** - * 更新记录,且可以指定作为条件的字段.Update record according to whereFields. - * @param entity 实体类对象,不能为空.table's entity(do not allow null). - * 没指定为whereFields的字段,作为set部分,默认只处理非空,非null的字段 - * @param whereFields 作为SQL中where条件的字段列表,多个字段用逗号隔开(列表中有的字段都会作为条件); - * 指定作为条件的,都转换.id为null不作为过滤条件 - * @return 成功更新的记录数,若失败则返回小于0的整数.the numbers of update record(s) successfully,if fails, return integer less than 0. + * Update record according to whereFields. + * @param entity table's entity(do not allow null). + *
Fields that are not specified as whereFields, as part of the set(only non empty and non null fields + *
are processed by default). + * @param whereFields As a field list of where part in SQL, multiple fields are separated by commas + *
(the fields in the list will be used as where filter) + *
But if id's value is null can not as filter. + * @return the numbers of update record(s) successfully,if fails, return integer less than 0. * @since 1.6 */ public int updateBy(T entity,String whereFields); /** - * 更新记录,且可以指定作为条件的字段和指定字段的过滤类型.Update record according to whereFields. - * @param entity 与表对应的实体对象,且不能为空 - * 没指定为whereFields的字段,作为set部分. - * @param whereFields 作为SQL中where条件的字段列表,多个字段用逗号隔开(列表中有的字段都会作为条件); - * 指定作为条件的,都转换.id为null不作为过滤条件 - * @param includeType 空字符串与null是否作为过滤条件.whether null string and null as a filter conditions. - * @return 成功更新的记录数,若失败则返回小于0的整数.the numbers of update record(s) successfully,if fails, return integer less than 0. + * Update record according to whereFields. + * @param entity table's entity(do not allow null). + *
Fields that are not specified as whereFields, as part of the set(only non empty and non null + *
fields are processed by default,can change the default use IncludeType parameter). + * @param whereFields As a field list of where part in SQL, multiple fields are separated by commas + *
(the fields in the list will be used as where filter) + *
But if id's value is null can not as filter. + * @param includeType whether null string and null as a filter conditions. + * @return the numbers of update record(s) successfully,if fails, return integer less than 0. * @since 1.6 */ public int updateBy(T entity,String whereFields,IncludeType includeType); /** - * 更新记录,且可以指定作为条件的字段.Update record according to whereFields. - * @param entity 实体类对象,不能为空.table's entity(do not allow null). - * 没指定为whereFields的字段,作为set部分(默认只处理非空,非null的字段) - * @param whereFields 作为SQL中where条件的字段列表,多个字段用逗号隔开(列表中有的字段都会作为条件); - * 指定作为条件的,都转换.id为null不作为过滤条件. - *
需要注意的是,用condition的op方法设置的条件,即使whereFields没有声明,也会转换. + * Update record according to whereFields. + * @param entity table's entity(do not allow null). + *
Fields that are not specified as whereFields, as part of the set(only non empty and non null fields + *
are processed by default). + * @param whereFields As a field list of where part in SQL, multiple fields are separated by commas + *
(the fields in the list will be used as where filter) + *
But if id's value is null can not as filter. *
Notice:the method op of condition also maybe converted to the where expression. - * @param condition 用来设置默认情况不能表达的条件. - * 若condition没有设置IncludeType,默认过滤NULL和空字符串(但condition中op,between,notBetween方法设置的字段,不受includeType的值影响.) - * @return 成功更新的记录数,若失败则返回小于0的整数.the numbers of update record(s) successfully,if fails, return integer less than 0. + * @param condition Condition as filter the record. + * @return the numbers of update record(s) successfully,if fails, return integer less than 0. * @since 1.7.2 */ public int updateBy(T entity,String whereFields,Condition condition); /** - * 此方法,相当于调用SuidRich接口的 updateBy(entity,"id",condition); it is equivalent to updateBy(entity,"id",condition) - * @param entity 实体类对象,不能为空.table's entity(do not allow null). - * entity中除了id字段,作为set部分(默认只处理非空,非null的字段) - * @param condition 用来设置默认情况不能表达的条件. - * 若condition没有设置IncludeType,默认过滤NULL和空字符串(但condition中op,between,notBetween方法设置的字段,不受includeType的值影响.) - *
需要注意的是,condition用op设置的条件,也有可能转换为where部分的过滤条件. - * @return 成功更新的记录数,若失败则返回小于0的整数.the numbers of update record(s) successfully,if fails, return integer less than 0. + * it is equivalent to updateBy(entity,"id",condition) + * @param entity table's entity(do not allow null). + *
In entity, except for the ID field, other fields are used as the set part (only non empty and non null + * fields are processed by default) + * @param condition Condition as filter the record. + *
It should be noted that the condition set by OP may also be converted to the filter condition of where. + * @return the numbers of update record(s) successfully,if fails, return integer less than 0. * @since 1.9 */ public int updateById(T entity,Condition condition); /** - * 更新记录,且可以指定需要更新的字段,高级条件可通过Condition参数设置.Update record, can list update fields. - * @param entity 实体类对象,不能为空.table's entity(do not allow null). - * entity默认有值的字段会转成field=value的形式,其它形式可通过condition指定.
- * If the field of entity is not null or empty, it will be translate to field=value.Other can define with condition.
- * @param updateFields 需要更新的字段列表,多个字段用逗号隔开(列表中有的字段都会更新),该属性不允许为空, - *
默认updateFields的每个字段会被转化成SQL update的set表达式;其它非空,非null的字段作为过滤条件,转成SQL的where表达式. - *
condition中setMultiply,setAdd,set方法设置的字段不受此限制.The methods setMultiply,setAdd,set in condition are not subject to this restriction. + * Update record, can list update fields. + * @param entity table's entity(do not allow null). + *
If the field of entity is not null or empty, it will be translate to field=value.Other can define with condition. + * @param updateFields update fields.The methods setMultiply,setAdd,set in condition are not subject to this restriction. *
For the list of fields to be updated, multiple fields are separated by commas (those fields will be updated). - *
This attribute cannot be empty and is not affected by the includeType parameter. By default, each field will be - *
converted to a set expression of SQL update. - * @param condition - * 若condition没有设置IncludeType,默认过滤NULL和空字符串(但condition中op,between,notBetween方法设置的字段,不受includeType的值影响.) - * 一个字段既在指定的updateFields,也用在了Condition.set(arg1,arg2)等方法设置,entity里相应的字段会按规则转化到where部分.(V1.9.8) - * @return 成功更新的记录数,若失败则返回小于0的整数.the numbers of update record(s) successfully,if fails, return integer less than 0. + *
This attribute cannot be empty and is not affected by the Condition's includeType parameter. By default, each + *
field will be converted to a set expression of SQL update. + * @param condition Condition as filter the record. + *
A field is used not only in the specified updateFields, but also in Condition.set(arg1,arg2), + *
and the corresponding fields in entity will be converted to the where part according to the rules (V1.9.8) + * @return the numbers of update record(s) successfully,if fails, return integer less than 0. * @since 1.7.2 */ public int update(T entity,String updateFields,Condition condition); /** - * 更新记录,高级条件可通过Condition参数设置 Update record,and can help with Condition. - *
当SQL update的set表达式通过Condition定义时,可以不用再指定set使用的字段. - *
此方法相当于调用update(T entity,String updateFields,Condition condition)方法时,将updateFields设置为"". + * Update record,and can help with Condition. + *
When the set expression of SQL update is defined by Condition, you can no longer specify the field used by set. *
it is equivalent to update(entity,"",condition),updateFields value is "". - * @param entity 实体类对象,不能为空.table's entity(do not allow null). - * entity默认有值的字段会转成field=value的形式(转到where部分),其它形式可通过condition指定.
- * If the field of entity is not null or empty, it will be translate to field=value in where part.Other can define with condition.
- * @param condition - * 若condition没有设置IncludeType,默认过滤NULL和空字符串(但condition中op,between,notBetween方法设置的字段,不受includeType的值影响.) - * @return 成功更新的记录数,若失败则返回小于0的整数.the numbers of update record(s) successfully,if fails, return integer less than 0. + * @param entity table's entity(do not allow null). + *
If the field of entity is not null or empty, it will be translate to field=value in where part.Other can define with condition. + * @param condition Condition as filter the record. + * @return the numbers of update record(s) successfully,if fails, return integer less than 0. * @since 1.8 */ public int update(T entity,Condition condition); /** - * 更新实体,oldEntity的非null,非空属性作为过虑条件;newEntity的非null,非空属性作为需要更新的字段对应值 - *
Update the entity. The non null and non empty attributes of oldEntity are taken as + * Update the entity. The non null and non empty attributes of oldEntity are taken as *
the filtering conditions; The non null and non empty properties of newEntity are *
used as the corresponding values of the properties to be updated - * 新旧实体必须是相同类型. - * Old and new entities must be of the same type. - * oldEntity转化为SQL的Where部分,newEntity改转化为Set部分. - * oldEntity is converted to Where part of SQL, and newEntity is converted to Set part. - * @param oldEntity 含有旧值属性的实体.Entity with old value field. - * @param newEntity 含有新值属性的实体.Entity with new value field. - * @return 成功更新的记录数,若失败则返回小于0的整数.the numbers of update record(s) successfully,if fails, return integer less than 0. + *
Old and new entities must be of the same type. + *
oldEntity is converted to Where part of SQL, and newEntity is converted to Set part. + *
The object-oriented Interceptor only processes the newEntity; + *
The oldEntity as conditions is not processed in the Interceptor. + * @param oldEntity Entity with old value field. + * @param newEntity Entity with new value field. + * @return the numbers of update record(s) successfully,if fails, return integer less than 0. */ public int update(T oldEntity,T newEntity); /** - * 为动态表名、实体名参数设置值.set dynamic parameter for dynamic table & entity name - *
本方法的调用要早于select,update,insert,delete等方法. + * set dynamic parameter for dynamic table & entity name *
This method is called earlier than the select, update, insert, delete methods. - *
本方法与Suid接口中的同名方法效果一样,只是为了方便链式编程. *
This method has the same effect as the same name method in suid interface, *
only for the convenience of chain programming * @param para parameter name @@ -587,20 +568,19 @@ public interface SuidRich extends Suid { public SuidRich setDynamicParameter(String para, String value); /** - * 检测实体对应记录是否存在.Check whether the entity corresponding record exist - * @param entity 实体类对象,不能为空.table's entity(do not allow null). + * Check whether the entity corresponding record exist + * @param entity table's entity(do not allow null). * @return true,if have the record;or return false. * @since 1.9 */ public boolean exist(T entity); /** - * 保存一个实体(一条记录).save one entity(one record). - * 如果可以区分开,建议明确调用insert(entity)或者update(entity),这样更加安全和高效. - * If it can be distinguished, it is recommended to explicitly call insert (entity) + * save one entity(one record). + *
If it can be distinguished, it is recommended to explicitly call insert (entity) *
or update (entity), which is more secure and efficient. * @param entity - * @return 返回受影响的行数,若失败则返回小于0的整数.the numbers of effect record(s),if fails, return integer less than 0. + * @return the numbers of effect record(s),if fails, return integer less than 0. * @since 1.9.8 */ public int save(T entity); diff --git a/src/main/java/org/teasoft/bee/osql/SuidType.java b/src/main/java/org/teasoft/bee/osql/SuidType.java index 30a832f354f29c40ebc61931ac50388c8ff56d30..d22ffc459df183654bea42ee40e2e3ea512c24de 100644 --- a/src/main/java/org/teasoft/bee/osql/SuidType.java +++ b/src/main/java/org/teasoft/bee/osql/SuidType.java @@ -18,35 +18,41 @@ package org.teasoft.bee.osql; /** - * 数据库Suid(Select,Update,Insert,Delete)操作类型.Database Suid(Select,Update,Insert,Delete) type. + * Database Suid(Select,Update,Insert,Delete) type. * @author Kingstar * @since 1.4 */ public enum SuidType { /** - * 对应SQL的SELECT操作.Select operation corresponding to SQL + * Select operation corresponding to SQL */ SELECT("SELECT"), /** - * 对应SQL的UPDATE操作.UPDATE operation corresponding to SQL + * UPDATE operation corresponding to SQL */ UPDATE("UPDATE"), /** - * 对应SQL的INSERT操作.INSERT operation corresponding to SQL + * INSERT operation corresponding to SQL */ INSERT("INSERT"), /** - * 对应SQL的DELETE操作.DELETE operation corresponding to SQL + * DELETE operation corresponding to SQL */ DELETE("DELETE"), /** - * 对应SQL的UPDATE,INSERT,DELETE操作.UPDATE,INSERT,DELETE operation corresponding to SQL + * UPDATE,INSERT,DELETE operation corresponding to SQL */ - MODIFY("MODIFY"); + MODIFY("MODIFY"), + + /** + * SELECT,UPDATE,INSERT,DELETE + * @since 1.11 + */ + SUID("SUID"); private String type; diff --git a/src/main/java/org/teasoft/bee/osql/UpperKey.java b/src/main/java/org/teasoft/bee/osql/UpperKey.java index a5f454762dde9b86d6c4ee29c93311996b32fea0..7dff9123947f812b16ccc3ce84ee1f7db912f895 100644 --- a/src/main/java/org/teasoft/bee/osql/UpperKey.java +++ b/src/main/java/org/teasoft/bee/osql/UpperKey.java @@ -18,134 +18,140 @@ package org.teasoft.bee.osql; /** - * SQL关键字的大写形式.SQL KeyWord's upper case. + * SQL KeyWord's upper case. * @author Kingstar * @since 1.8.99 */ public class UpperKey implements SqlKeyWord { - - private static final String SPACE=" "; - private static final String select="SELECT"; - private static final String as="AS"; - private static final String from="FROM"; - private static final String where="WHERE"; - private static final String insert="INSERT"; - private static final String into="INTO"; - private static final String values="VALUES"; - private static final String and="AND"; - private static final String or="OR"; - private static final String Null="NULL"; - private static final String isNull="IS NULL"; - private static final String isNotNull="IS NOT NULL"; - private static final String update="UPDATE"; - private static final String set="SET"; - private static final String delete="DELETE"; - private static final String orderBy="ORDER BY"; - private static final String count="COUNT"; - private static final String asc="ASC"; - private static final String on="ON"; - - private static final String limit="LIMIT"; - private static final String offset="OFFSET"; - private static final String top="TOP"; - - private static final String groupBy="GROUP BY"; - private static final String having="HAVING"; - private static final String between="BETWEEN"; - private static final String notBetween="NOT BETWEEN"; - - private static final String forUpdate="FOR UPDATE"; - - private static final String distinct="DISTINCT"; - private static final String join="JOIN"; - private static final String innerJoin="INNER JOIN"; - private static final String leftJoin="LEFT JOIN"; - private static final String rightJoin="RIGHT JOIN"; - private static final String in="IN"; - private static final String notIn="NOT IN"; - private static final String exists="EXISTS"; - private static final String notExists="NOT EXISTS"; - + + private static final String SPACE = " "; + private static final String SELECT = "SELECT"; + private static final String AS = "AS"; + private static final String FROM = "FROM"; + private static final String WHERE = "WHERE"; + private static final String INSERT = "INSERT"; + private static final String REPLACE = "REPLACE"; + private static final String INTO = "INTO"; + private static final String VALUES = "VALUES"; + private static final String AND = "AND"; + private static final String OR = "OR"; + private static final String NULL = "NULL"; + private static final String ISNULL = "IS NULL"; + private static final String isNotNull = "IS NOT NULL"; + private static final String UPDATE = "UPDATE"; + private static final String SET = "SET"; + private static final String DELETE = "DELETE"; + private static final String orderBy = "ORDER BY"; + private static final String COUNT = "COUNT"; + private static final String ASC = "ASC"; + private static final String ON = "ON"; + + private static final String LIMIT = "LIMIT"; + private static final String OFFSET = "OFFSET"; + private static final String TOP = "TOP"; + + private static final String groupBy = "GROUP BY"; + private static final String HAVING = "HAVING"; + private static final String BETWEEN = "BETWEEN"; + private static final String notBetween = "NOT BETWEEN"; + + private static final String forUpdate = "FOR UPDATE"; + + private static final String DISTINCT = "DISTINCT"; + private static final String JOIN = "JOIN"; + private static final String innerJoin = "INNER JOIN"; + private static final String leftJoin = "LEFT JOIN"; + private static final String rightJoin = "RIGHT JOIN"; + private static final String IN = "IN"; + private static final String notIn = "NOT IN"; + private static final String EXISTS = "EXISTS"; + private static final String notExists = "NOT EXISTS"; + @Override public String select() { - return select; + return SELECT; } - + @Override public String as() { - return as; + return AS; } @Override public String from() { - return from; + return FROM; } @Override public String where() { - return where; + return WHERE; } - + @Override public String insert() { - return insert; + return INSERT; + } + + @Override + public String replace() { + return REPLACE; } @Override public String into() { - return into; + return INTO; } - + @Override public String values() { - return values; + return VALUES; } @Override public String and() { - return and; + return AND; } @Override public String or() { - return or; + return OR; } - + @Override public String Null() { - return Null; + return NULL; } @Override public String isNull() { - return isNull; + return ISNULL; } @Override public String isNotNull() { return isNotNull; } - + @Override public String space() { return SPACE; } - + @Override public String update() { - return update; + return UPDATE; } @Override public String set() { - return set; + return SET; } @Override public String delete() { - return delete; + return DELETE; } - + @Override public String orderBy() { return orderBy; @@ -153,17 +159,17 @@ public class UpperKey implements SqlKeyWord { @Override public String count() { - return count; + return COUNT; } @Override public String asc() { - return asc; + return ASC; } @Override public String on() { - return on; + return ON; } @Override @@ -173,19 +179,19 @@ public class UpperKey implements SqlKeyWord { @Override public String limit() { - return limit; + return LIMIT; } @Override public String offset() { - return offset; + return OFFSET; } @Override public String top() { - return top; + return TOP; } - + @Override public String groupBy() { return groupBy; @@ -193,27 +199,27 @@ public class UpperKey implements SqlKeyWord { @Override public String having() { - return having; + return HAVING; } @Override public String between() { - return between; + return BETWEEN; } @Override public String notBetween() { return notBetween; } - + @Override public String distinct() { - return distinct; + return DISTINCT; } @Override public String join() { - return join; + return JOIN; } @Override @@ -233,7 +239,7 @@ public class UpperKey implements SqlKeyWord { @Override public String in() { - return in; + return IN; } @Override @@ -243,12 +249,12 @@ public class UpperKey implements SqlKeyWord { @Override public String exists() { - return exists; + return EXISTS; } @Override public String notExists() { return notExists; } - + } diff --git a/src/main/java/org/teasoft/bee/osql/annotation/Column.java b/src/main/java/org/teasoft/bee/osql/annotation/Column.java new file mode 100644 index 0000000000000000000000000000000000000000..96250ab4b5dc28cc469fe18c6977dfc751c5ee2f --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/annotation/Column.java @@ -0,0 +1,71 @@ +/* + * Copyright 2020-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Table column names and Javabean field names mapping annotation, + * To use @column, open the openDefineColumn configuration and realize the mapping function. +


+

Where will detect this annotation: +

Object oriented way: Suid,SuidRich,MoreTable will detect. +

The create SQL command (Ddl.java) generated according to the Javabean will detect. +

Where will not detect this annotation: +

Entities in PreparedSql are used as return types, and column annotations are not detected for entities. +

Mapsuid will not detect +

JustFetch annotated fields should not be annotated with Column. +


+

Notice: the mapping implementation needs to be developed by the user(implement the ColumnHandler interface, +

and use NameTranslateHandle.setColumnHandler(columnHandler) to set). +

The use of Column annotation is not officially recommended base the bellow reason. +


+

Benefits of not using Column annotation: +

Convention-over-configuration, automatic naming mapping can be used, and the rules are simple. +

You can use the Bee framework to automatically generate the Javabean corresponding to the table. +

The table structure is changed and easy to maintain. It can be automatically generated again. +

Keep appropriate redundancy. Fields such as creation time and creator do not need to be moved to the parent class,
+

the table can correspond to the Javabean without too much manual intervention. It can save more time to focus on business logic. +

The processing speed is faster. +


+

Solution: +

1)Suid,SuidRich,MoreTable will parse entity to sql automatically; +

2)Moretable can also handle the situation that different tables have duplicate name fields and different DB paging syntax. +

3)Custom SQL, alias with "as"(select column_name as java_field_name),
+

The query results can be automatically parsed to the given Javabean structure. +

4)Ignore field can use @Ignore +

5)Using JustFetch annotation +

@ JustFetch("CONCAT(fisrt_name,last_name)") +

private String fullname; +

-->select CONCAT(fisrt_name,last_name) as fullname +

@ JustFetch("name") +

private String name2; +

-->select name as name2 + + * @author Kingstar + * @since 1.11 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Column { + @Deprecated + String value(); +} diff --git a/src/main/java/org/teasoft/bee/osql/annotation/Createtime.java b/src/main/java/org/teasoft/bee/osql/annotation/Createtime.java new file mode 100644 index 0000000000000000000000000000000000000000..e98dabbb9726693f73ecf29108c0716b55010e87 --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/annotation/Createtime.java @@ -0,0 +1,35 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Generate creation time(current time) automatically when insert records. + * @author Kingstar + * @since 1.11 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Createtime { + String formatter() default ""; + boolean override() default false; +} diff --git a/src/main/java/org/teasoft/bee/osql/annotation/Datetime.java b/src/main/java/org/teasoft/bee/osql/annotation/Datetime.java new file mode 100644 index 0000000000000000000000000000000000000000..e4e6fdef527e5f2af0d7deec85ab22b3c53a0dba --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/annotation/Datetime.java @@ -0,0 +1,42 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.teasoft.bee.osql.SuidType; + +/** + * Datetime annotation + * @author Kingstar + * @since 1.11 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Datetime { + + String formatter() default ""; + + boolean override() default false; + + SuidType suidType(); + +} diff --git a/src/main/java/org/teasoft/bee/osql/annotation/Dict.java b/src/main/java/org/teasoft/bee/osql/annotation/Dict.java new file mode 100644 index 0000000000000000000000000000000000000000..fb8dfbf9301faf67c094420a07351d32f17103c2 --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/annotation/Dict.java @@ -0,0 +1,59 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Dictionary conversion annotation is used to filter and process the returned data + *
of query according to rules. If there is no mapping, it will not be replaced. + *
Version 1.11, general processing implementation is not provided yet +

+

data in Databsee: +

flag=null +

flag=1 +

flag=0 +

flag= +

@ Dict(map="0=No,1=Yes",nullToValue="?") +

@ Dict(map="0=No,1=Yes,=empty,",nullToValue="?") +

private String flag; +

after process: +

flag=? +

flag=Yes +

flag=No +

flag=empty + + * @author Kingstar + * @since 1.11 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Dict { + + String map(); + + /** + * The value of the replacement when the field value is null. + * @return value replace for null + */ + String nullToValue() default "@#placeholderStr(default do not process)"; + +} diff --git a/src/main/java/org/teasoft/bee/osql/annotation/Entity.java b/src/main/java/org/teasoft/bee/osql/annotation/Entity.java index bdfea8be121664c9da0502f210b35293e646cf60..3928aec8b0c6151fa40fe2e37b1248de4c7b66dc 100644 --- a/src/main/java/org/teasoft/bee/osql/annotation/Entity.java +++ b/src/main/java/org/teasoft/bee/osql/annotation/Entity.java @@ -24,7 +24,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Entity注解解析动态命名参数后还需要命名转换.Dynamic named for Javabean. + * Dynamic named for Javabean. * @author Kingstar * @since 1.8 */ diff --git a/src/main/java/org/teasoft/bee/osql/annotation/Ignore.java b/src/main/java/org/teasoft/bee/osql/annotation/Ignore.java index e310459a0366b8f0edef6cbfd609f4341cec913f..6d16532130c13598d467add3881184daa69987eb 100644 --- a/src/main/java/org/teasoft/bee/osql/annotation/Ignore.java +++ b/src/main/java/org/teasoft/bee/osql/annotation/Ignore.java @@ -23,8 +23,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * 忽略不想转换的字段.Ignore the field which do not want to transfer. - *
建议尽可能少用该注解,因为很多时间你可以用默认忽略null/空字符的特性达到同样的效果. + * Ignore the field which do not want to transfer. *
It is recommended that the annotation be used as little as possible, *
because many times you can use the following features to achieve the same effect: *
the null and empty string are not handled by default. diff --git a/src/main/java/org/teasoft/bee/osql/annotation/JoinTable.java b/src/main/java/org/teasoft/bee/osql/annotation/JoinTable.java index 96bd82020193853384cfb58ae5f905ca50e70e5b..2a3d988ce1f4ee2579579e08959617dd29c6de7a 100644 --- a/src/main/java/org/teasoft/bee/osql/annotation/JoinTable.java +++ b/src/main/java/org/teasoft/bee/osql/annotation/JoinTable.java @@ -23,7 +23,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * 用于表连接的注解.Annotation for tables join. + * Annotation for tables join. * @author Kingstar * @since 1.7 */ @@ -31,35 +31,48 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) public @interface JoinTable { - JoinType joinType() default JoinType.JOIN; //join type: left join,right join,join (full join) - // String mainEntity(); - // String subEntity(); + /** + * JoinType: left join,right join,join, (full join need DB support) + * @return JoinType + */ + JoinType joinType() default JoinType.JOIN; /** - * 主表关联的字段.The join on field of main table. + * The join on field of main table. * @return main table's join field name. */ String mainField() default ""; /** - * 从表关联的字段.The join on field of subtable. + * The join on field of subtable. * @return subtable's join field name. */ String subField() default ""; /** - * 从表别名.Subtable alias. + * Subtable alias. * @return subtable alias. */ String subAlias() default ""; /** - * 从表的class类型;与主表实体在同一包下,可以只写类名.(在使用List类型的从表时才有效) * Subtable class type, if it has same package with main table,the package name can be omitted. * (effect when using a list type Subtable) + * replace by subClazz() since 1.11 * @return sub Class name. * @since 1.9.8 + * @deprecated (since="1.11",can use subClazz() replace it.) */ + @Deprecated() String subClass() default ""; + + /** + * Subtable entity Class type. + * (effect when using a list type Subtable) + * @return subClass Class type. + * @since 1.11 + */ + @SuppressWarnings("rawtypes") + Class subClazz() default Object.class; } diff --git a/src/main/java/org/teasoft/bee/osql/annotation/JoinType.java b/src/main/java/org/teasoft/bee/osql/annotation/JoinType.java index 8b9ab2d16682377a0c16eb23385161a9d6c2083d..93fe3193855552b5855c724d1d327f33a43a4887 100644 --- a/src/main/java/org/teasoft/bee/osql/annotation/JoinType.java +++ b/src/main/java/org/teasoft/bee/osql/annotation/JoinType.java @@ -18,7 +18,7 @@ package org.teasoft.bee.osql.annotation; /** - * SQL连接类型.SQL join type. + * SQL join type. * @author Kingstar * @since 1.7 */ diff --git a/src/main/java/org/teasoft/bee/osql/annotation/JustFetch.java b/src/main/java/org/teasoft/bee/osql/annotation/JustFetch.java new file mode 100644 index 0000000000000000000000000000000000000000..2940ce3cd633a3d27b7c6d928020e18f73df004b --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/annotation/JustFetch.java @@ -0,0 +1,47 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * It is used to query and obtain record information, + * but not as a filter condition in WHERE part. + * +

eg: +

@ JustFetch("CONCAT(fisrt_name,last_name)") //multiple tables maybe need bring the table name +

private String fullname; +

--> select CONCAT(fisrt_name,last_name) as fullname + +

map field name and column name,but can not transform to where part +

eg: +

@ JustFetch("name") +

private String name2; +

-->select name as name2 + + * @author Kingstar + * @since 1.11 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface JustFetch { + String value(); +} diff --git a/src/main/java/org/teasoft/bee/osql/annotation/PrimaryKey.java b/src/main/java/org/teasoft/bee/osql/annotation/PrimaryKey.java new file mode 100644 index 0000000000000000000000000000000000000000..6bfcdb1db3b6ea9fc6556773f37b1aca54e99292 --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/annotation/PrimaryKey.java @@ -0,0 +1,29 @@ +/* + * Copyright 2016-2021 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * The license,see the LICENSE file. + */ + +package org.teasoft.bee.osql.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Mark an property as the Primary Key.
+ * It is not allowed to define a field named ID, but it is not defined as a primary key.
+ * When the field name of the primary key is not "id", it can be marked as the primary
+ * key with the PrimaryKey annotation.
+ * When the field has Ignore annotation, the PrimaryKey annotation will also be ignored.
+ * This annotation exists for compatibility with old systems,
+ * It is strongly recommended to set an "id" column as the primary key when defining table in the new system. + * @author Kingstar + * @since 1.11 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface PrimaryKey { + +} diff --git a/src/main/java/org/teasoft/bee/osql/annotation/ReplaceInto.java b/src/main/java/org/teasoft/bee/osql/annotation/ReplaceInto.java new file mode 100644 index 0000000000000000000000000000000000000000..3bca8e0432993683f5ae69bfd7a56636b71b47f6 --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/annotation/ReplaceInto.java @@ -0,0 +1,35 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Change "insert [into]" to "replace [into]" for insert sql. + * In particular, this is generally used for MySQL. + * @author Kingstar + * @since 1.11 + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface ReplaceInto { + +} diff --git a/src/main/java/org/teasoft/bee/osql/annotation/SysValue.java b/src/main/java/org/teasoft/bee/osql/annotation/SysValue.java index 1dc4cdbd5aa2f69c73d8e431d4407078441a2aaa..02c46eb4ac46cff78759ee7cf89979b3371dc5e2 100644 --- a/src/main/java/org/teasoft/bee/osql/annotation/SysValue.java +++ b/src/main/java/org/teasoft/bee/osql/annotation/SysValue.java @@ -23,7 +23,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Bee框架内部使用的注解,用于将properties文件的值设置到类属性.Annotation use in Bee for setting class' field value by properties. + * Annotation use in Bee for setting class' field value by properties. * @author Kingstar * @since 1.4 */ diff --git a/src/main/java/org/teasoft/bee/osql/annotation/Table.java b/src/main/java/org/teasoft/bee/osql/annotation/Table.java index 2fe8e36cbac1948a8a529faa400441987e6a6b28..e49f1be674f9f0ec0c43aaafcbba453f7424de9e 100644 --- a/src/main/java/org/teasoft/bee/osql/annotation/Table.java +++ b/src/main/java/org/teasoft/bee/osql/annotation/Table.java @@ -24,7 +24,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * 指定或动态表名映射,Table注解不再需要命名转换.Specify or dynamic table name mapping,do not auto translate next. + * Specify or dynamic table name mapping,the value do not auto translate any more. * @author Kingstar * @since 1.8 */ diff --git a/src/main/java/org/teasoft/bee/osql/annotation/Updatetime.java b/src/main/java/org/teasoft/bee/osql/annotation/Updatetime.java new file mode 100644 index 0000000000000000000000000000000000000000..09ee9f4b0466d793ceee7594e458db2b1aad818d --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/annotation/Updatetime.java @@ -0,0 +1,26 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * The license,see the LICENSE file. + */ + +package org.teasoft.bee.osql.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * When updat records, the update time is automatically filled in as the current time. + * If the original field has a value, it will not be override by default. + * @author Kingstar + * @since 1.11 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Updatetime { + String formatter() default ""; + + boolean override() default false; +} diff --git a/src/main/java/org/teasoft/bee/osql/annotation/customizable/AbstractDictI18nDefaultHandler.java b/src/main/java/org/teasoft/bee/osql/annotation/customizable/AbstractDictI18nDefaultHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..2014b51479fd3a30a2e47c37ddb3d4b2a166ce88 --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/annotation/customizable/AbstractDictI18nDefaultHandler.java @@ -0,0 +1,36 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql.annotation.customizable; + +import java.lang.reflect.Field; +import java.util.List; + +/** + * Abstract DictI18n Default Handler. + * @author Kingstar + * @since 1.11 + */ +public abstract class AbstractDictI18nDefaultHandler implements BeforeReturnAnnotationHandler { + + @Override + @SuppressWarnings("rawtypes") + public void process(Field field, List list) { + + } + +} diff --git a/src/main/java/org/teasoft/bee/osql/annotation/customizable/AnnotationHandler.java b/src/main/java/org/teasoft/bee/osql/annotation/customizable/AnnotationHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..b5675bdc58275fab70f54a37e09907da09cfa99b --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/annotation/customizable/AnnotationHandler.java @@ -0,0 +1,36 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql.annotation.customizable; + +import java.util.Map; + +/** + * Annotation Handler Interface. + * @author Kingstar + * @since 1.11 + */ +public interface AnnotationHandler { + + public String process(); + + public String process(String s); + + @SuppressWarnings("rawtypes") + public String process(Map para); + +} diff --git a/src/main/java/org/teasoft/bee/osql/annotation/customizable/AutoSetString.java b/src/main/java/org/teasoft/bee/osql/annotation/customizable/AutoSetString.java new file mode 100644 index 0000000000000000000000000000000000000000..cebde2529ce4c80c9a0cc6d943789bbf6525d415 --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/annotation/customizable/AutoSetString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql.annotation.customizable; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.teasoft.bee.osql.SuidType; + +/** + * Automatically setting the fields remark by AutoSetValue annotation. + *
The setting value is provided by the class specified by the handler. + *
The field type needs to be java.lang.String. + * @author Kingstar + * @since 1.11 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface AutoSetString { + boolean override() default false; + + SuidType suidType(); + + Class handler(); +} diff --git a/src/main/java/org/teasoft/bee/osql/annotation/customizable/BeforeReturnAnnotationHandler.java b/src/main/java/org/teasoft/bee/osql/annotation/customizable/BeforeReturnAnnotationHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..8123df9ea84265a867ca0e6009e2a67b7aa04e51 --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/annotation/customizable/BeforeReturnAnnotationHandler.java @@ -0,0 +1,38 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql.annotation.customizable; + +import java.lang.reflect.Field; +import java.util.List; + +/** + * Annotation Handler Interface trigger on before return. + * @author Kingstar + * @since 1.11 + */ +public interface BeforeReturnAnnotationHandler { + + /** + * + * @param field Field with corresponding annotation + * @param list List of annotations to be processed + */ + @SuppressWarnings("rawtypes") + public void process(Field field,List list); + +} diff --git a/src/main/java/org/teasoft/bee/osql/annotation/customizable/ColumnHandler.java b/src/main/java/org/teasoft/bee/osql/annotation/customizable/ColumnHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..f5e6f7039cd22c4e5df18d23da6f484683db9299 --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/annotation/customizable/ColumnHandler.java @@ -0,0 +1,45 @@ +/* + * Copyright 2020-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql.annotation.customizable; + +/** + * Column Annotation handler interface. + * @author Kingstar + * @since 1.11 + */ +@SuppressWarnings("rawtypes") +public interface ColumnHandler { + + /** + * translate to Column Name. + * @param fieldName field name + * @param entityClass entity class + * @return column name. + */ + public String toColumnName(String fieldName, Class entityClass); + + + /** + * translate to Field Name. + * @param columnName column name + * @param entityClass entity class + * @return field name. + */ + public String toFieldName(String columnName, Class entityClass); + +} diff --git a/src/main/java/org/teasoft/bee/osql/annotation/customizable/Desensitize.java b/src/main/java/org/teasoft/bee/osql/annotation/customizable/Desensitize.java new file mode 100644 index 0000000000000000000000000000000000000000..395324bce27b6cffbf57881af1ff880dca729d8d --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/annotation/customizable/Desensitize.java @@ -0,0 +1,57 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql.annotation.customizable; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Starting from the specified position, change the specified size of characters to mask characters. + *
eg: + *
\@Desensitize(start=5, size=2, mask="*") + *
private String sequence; + *
sequence in the database is: 0123456789 + *
after process: + *
sequence=01234**789 + * + * @author Kingstar + * @since 1.11 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Desensitize { + /** + * Start position (starting from 0) + * @return start position + */ + int start(); + + /** + * the number of characters need to replace + * @return the number of characters need to replace + */ + int size(); + + /** + * Mask used + * @return mask code + */ + String mask(); +} diff --git a/src/main/java/org/teasoft/bee/osql/annotation/customizable/DictI18n.java b/src/main/java/org/teasoft/bee/osql/annotation/customizable/DictI18n.java new file mode 100644 index 0000000000000000000000000000000000000000..245db3af17febe86a279e31f51cd067176375f58 --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/annotation/customizable/DictI18n.java @@ -0,0 +1,36 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql.annotation.customizable; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Support international multi language dictionary conversion annotation, + * which is generally used for global unified setting. + *
It is used to filter and process the returned data of query according to rules. + * @author Kingstar + * @since 1.11 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface DictI18n { + +} diff --git a/src/main/java/org/teasoft/bee/osql/annotation/customizable/DsTabHandler.java b/src/main/java/org/teasoft/bee/osql/annotation/customizable/DsTabHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..aef6b3949a7413544451397b951284c051d1b897 --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/annotation/customizable/DsTabHandler.java @@ -0,0 +1,32 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql.annotation.customizable; + +import org.teasoft.bee.distribution.sharding.DsTabStruct; +import org.teasoft.bee.distribution.sharding.ShardingStruct; + +/** + * DataSource and Table Handler + * @author Kingstar + * @since 1.11 + */ +public interface DsTabHandler { + + public DsTabStruct process(ShardingStruct shardingStruct); + +} diff --git a/src/main/java/org/teasoft/bee/osql/annotation/customizable/Json.java b/src/main/java/org/teasoft/bee/osql/annotation/customizable/Json.java new file mode 100644 index 0000000000000000000000000000000000000000..7f5466764ccf8f71463c59f838afa05ce40ca350 --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/annotation/customizable/Json.java @@ -0,0 +1,38 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql.annotation.customizable; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * The entity structure is converted to Jason when inserting values, + *
and the Jason string is converted to entity structure when querying. + *
Only valid when inserting values and query fields, not as a where condition. + *
When update can only be used in entities and cannot be set with condition. + *
need register to TypeHandlerRegistry and SetParaTypeConverterRegistry. + * @author Kingstar + * @since 1.11 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Json { + +} diff --git a/src/main/java/org/teasoft/bee/osql/annotation/customizable/JsonHandler.java b/src/main/java/org/teasoft/bee/osql/annotation/customizable/JsonHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..9d748ad122dc1a11ebcc68a85b8428d15fb2d44c --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/annotation/customizable/JsonHandler.java @@ -0,0 +1,16 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * The license,see the LICENSE file. + */ + +package org.teasoft.bee.osql.annotation.customizable; + +/** + * Json annotation Handler,is not necessary. + * @author Kingstar + * @since 1.11 + */ +public interface JsonHandler { + +} diff --git a/src/main/java/org/teasoft/bee/osql/annotation/customizable/MultiTenancy.java b/src/main/java/org/teasoft/bee/osql/annotation/customizable/MultiTenancy.java new file mode 100644 index 0000000000000000000000000000000000000000..b528b381e35d52fdfd73996d6e24e96a41d116e6 --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/annotation/customizable/MultiTenancy.java @@ -0,0 +1,97 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql.annotation.customizable; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Multi-tenancy. + *
Specify different tables in the same database after calculation; Specify different databases after calculation. + *
When there are multiple tables, cross table is not supported. + *
The dataSource of the sub table is consistent with the main table. + *
Order: 1->2 + *
1. Special (if special is configured, others will not be detected) + *
2. Calculate by algorithm (default if there is no match) + * @author Kingstar + * @since 1.11 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface MultiTenancy { + + /** + * appoint dataSource + * @return appointed dataSource + */ + String appointDS() default ""; + + /** + * appoint table name + * @return appointed table name + */ + String appointTab() default ""; + + /** + * 0: operations that can be calculated directly such as remainder; 1: Take part of the string such as date; 2: Custom + * @return value of dsAlgorithm + */ + int dsAlgorithm() default 0; + + /** + * 0: operations that can be calculated directly such as remainder; 1: Take part of the string such as date; 2: Custom + * @return value of tabAlgorithm + */ + int tabAlgorithm() default 0; + + /** + * If dsRule is not set, that is, the default empty value is used, it means that is not to consider the database name. + *
eg: "id%dsSize + * @return value of dsRule + */ + String dsRule() default ""; + + /** + * If dsRule is empty and the value of dsName is not set, the database name is not required. + *
By default, the value calculated by dsRule() will be automatically used as the suffix of dsName. + * @return dsName + */ + String dsName() default ""; + + /** + * get tabRule + * @return tabRule + */ + String tabRule() default ""; + /** + * get tabName. + *
The default is the value calculated by tabRule() as the suffix of tabName. + *
eg:tab${tabRule} + * @return tabName + */ + String tabName() default ""; + + /** + * use for define DsTabHandler. + * @return class of DsTabHandler type + */ + Class handler() default DsTabHandler.class; + +} diff --git a/src/main/java/org/teasoft/bee/osql/chain/Select.java b/src/main/java/org/teasoft/bee/osql/chain/Select.java index 10daf2f7c7820cfdee420f9363e6b446482687be..8d8d0d112fa28cf81467209030c9e42730e5e4a3 100644 --- a/src/main/java/org/teasoft/bee/osql/chain/Select.java +++ b/src/main/java/org/teasoft/bee/osql/chain/Select.java @@ -20,7 +20,7 @@ import org.teasoft.bee.osql.Op; import org.teasoft.bee.osql.OrderType; /** - * Select接口,用于链式风格写SQL语句.Select interface for SQL with chain programming. + * Select interface for SQL with chain programming. * @author Kingstar * @since 1.3 */ @@ -29,27 +29,27 @@ public interface Select extends ToSql{ //<==============condition start /** - * 添加左括号.add "(" + * add "(" * @return Update */ public Select lParentheses(); /** - * 添加右括号.add ")" + * add ")" * @return Update */ public Select rParentheses(); - public Select op(String field, Op Op, String value); + public Select op(String field, Op op, String value); - public Select op(String field, Op Op, Number value); + public Select op(String field, Op op, Number value); public Select op(String field, String value); public Select op(String field, Number value); /** - * 默认自动加and. Default will automatically add and. + * Default will automatically add and. * @return Select */ public Select and(); diff --git a/src/main/java/org/teasoft/bee/osql/chain/ToSql.java b/src/main/java/org/teasoft/bee/osql/chain/ToSql.java index c57da0eb36310d4ae0f85b2cc09b77001a841674..b48e323b16000d6a4e68ada9e1e43fb690b04b65 100644 --- a/src/main/java/org/teasoft/bee/osql/chain/ToSql.java +++ b/src/main/java/org/teasoft/bee/osql/chain/ToSql.java @@ -17,21 +17,21 @@ package org.teasoft.bee.osql.chain; /** - * ToSql接口,用于链式风格写SQL语句.ToSql interface for SQL with chain programming. + * ToSql interface for SQL with chain programming. * @author Kingstar * @since 1.3 */ public interface ToSql { /** - * 转成SQL语句. to SQL statement. - * @return sql语句.sql statement. + * to SQL statement. + * @return sql statement. */ public String toSQL(); /** - * 转成SQL语句. to SQL statement. - * @param noSemicolon 为true时,不包含分号.true means: no semicolon. - * @return sql语句.sql statement. + * to SQL statement. + * @param noSemicolon true means: no semicolon. + * @return sql statement. */ public String toSQL(boolean noSemicolon); } diff --git a/src/main/java/org/teasoft/bee/osql/chain/UnionSelect.java b/src/main/java/org/teasoft/bee/osql/chain/UnionSelect.java index 86a7166109a79a64162662202035285e966f0da6..7185db51276dbc0b3af4ed78fccc43cb7a084b33 100644 --- a/src/main/java/org/teasoft/bee/osql/chain/UnionSelect.java +++ b/src/main/java/org/teasoft/bee/osql/chain/UnionSelect.java @@ -17,7 +17,7 @@ package org.teasoft.bee.osql.chain; /** - * UnionSelect接口,用于链式风格写SQL语句.UnionSelect interface for SQL with chain programming. + * UnionSelect interface for SQL with chain programming. * @author Kingstar * @since 1.3 */ diff --git a/src/main/java/org/teasoft/bee/osql/chain/Update.java b/src/main/java/org/teasoft/bee/osql/chain/Update.java index b8144bac1ffd7906346424a00e4bd0390e8914c8..e8abd6433944b9b0078d91700c652fb0411585fe 100644 --- a/src/main/java/org/teasoft/bee/osql/chain/Update.java +++ b/src/main/java/org/teasoft/bee/osql/chain/Update.java @@ -19,7 +19,7 @@ package org.teasoft.bee.osql.chain; import org.teasoft.bee.osql.Op; /** - * Update接口,用于链式风格写SQL语句.Update interface for SQL with chain programming. + * Update interface for SQL with chain programming. * @author Kingstar * @since 1.3 */ @@ -32,27 +32,27 @@ public interface Update extends ToSql{ //<==============condition /** - * 添加左括号.add "(" + * add "(" * @return Update */ public Update lParentheses(); /** - * 添加右括号.add ")" + * add ")" * @return Update */ public Update rParentheses(); - public Update op(String field, Op Op, String value); + public Update op(String field, Op op, String value); - public Update op(String field, Op Op, Number value); + public Update op(String field, Op op, Number value); public Update op(String field, String value); public Update op(String field, Number value); /** - * 默认自动加and. Default will automatically add and. + * Default will automatically add and. * @return Select */ public Update and(); diff --git a/src/main/java/org/teasoft/bee/osql/dialect/DbFeature.java b/src/main/java/org/teasoft/bee/osql/dialect/DbFeature.java index c46b81bb80f223c8df2c661d72e6a1b94bf28ee8..868fab2001fc3776a347409029cc1833bffa547c 100644 --- a/src/main/java/org/teasoft/bee/osql/dialect/DbFeature.java +++ b/src/main/java/org/teasoft/bee/osql/dialect/DbFeature.java @@ -1,44 +1,44 @@ -/* - * Copyright 2013-2018 the original author.All rights reserved. - * Kingstar(honeysoft@126.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.teasoft.bee.osql.dialect; - -/** - * 为特定DB转换成对应的sql.Translate the sql for really DB. - * @author Kingstar - * @since 1.0 - */ -public interface DbFeature { - - /** - * 为SQL添加分页部分的语句.add the page part for sql. - * @param sql sql语句 - * @param start 开始下标(从0或1开始,eg:MySQL是0,Oracle是1). start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). - * @param size 结果集大小 大于等于1. fetch result size (>0). - * @return 返回增加分页功能的sql. Return paging sql. - */ - public String toPageSql(String sql,int start,int size); - - /** - * 为SQL添加分页部分的语句,默认从第0或1条记录开始返回.add the page part for sql,default start index,min value is 0 or 1 - * it is equal: toPageSql(sql,0,size) - * @param sql sql语句 - * @param size 结果集大小 大于等于1. fetch result size (>0). - * @return 返回增加分页功能的sql. Return paging sql. - */ - public String toPageSql(String sql, int size); -} +/* + * Copyright 2013-2018 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql.dialect; + +/** + * Translate the sql for really DB. + * @author Kingstar + * @since 1.0 + */ +public interface DbFeature { + + /** + * add the page part for sql. + * @param sql sql statement + * @param start start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). + * @param size fetch result size (>0). + * @return paging sql. + */ + public String toPageSql(String sql,int start,int size); + + /** + * add the page part for sql,default start index,min value is 0 or 1 + * it is equal: toPageSql(sql,0,size) + * @param sql sql statement + * @param size fetch result size (>0). + * @return paging sql. + */ + public String toPageSql(String sql, int size); +} diff --git a/src/main/java/org/teasoft/bee/osql/dialect/DbFeatureRegistry.java b/src/main/java/org/teasoft/bee/osql/dialect/DbFeatureRegistry.java new file mode 100644 index 0000000000000000000000000000000000000000..3fa0087fe81f7334fc874010cd6ef334fc8d7c8d --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/dialect/DbFeatureRegistry.java @@ -0,0 +1,51 @@ +/* + * Copyright 2020-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql.dialect; + +import java.util.HashMap; +import java.util.Map; + +import org.teasoft.bee.osql.Registry; + +/** + * DbFeature Registry + * @author Kingstar + * @since 1.11 + */ +public class DbFeatureRegistry implements Registry{ + private static final Map dbFeatureMap = new HashMap<>(); + + /** + * register DbFeature for database. + * databaseName can use DatabaseConst. + * @param databaseName database name + * @param dbFeature Implementation class of dbfeature. + */ + public static void register(String databaseName, DbFeature dbFeature) { + dbFeatureMap.put(databaseName, dbFeature); + } + + /** + * get register DbFeature by database name. + * @param databaseName database name + * @return instance of DbFeature. + */ + public static DbFeature getDbFeature(String databaseName) { + return dbFeatureMap.get(databaseName); + } +} diff --git a/src/main/java/org/teasoft/bee/osql/exception/BeeErrorFieldException.java b/src/main/java/org/teasoft/bee/osql/exception/BeeErrorFieldException.java index a184a31222fbd76d553acc2dc38730ee6fde5c17..dda1a056871023907aa4003506ced41362030ea4 100644 --- a/src/main/java/org/teasoft/bee/osql/exception/BeeErrorFieldException.java +++ b/src/main/java/org/teasoft/bee/osql/exception/BeeErrorFieldException.java @@ -20,7 +20,7 @@ package org.teasoft.bee.osql.exception; import org.teasoft.bee.osql.ObjSQLException; /** - * Bee面向对象实体转SQL错误字段异常.Bee error field exception. + * Bee error field exception. * @author Kingstar * @since 1.4 */ diff --git a/src/main/java/org/teasoft/bee/osql/exception/BeeErrorGrammarException.java b/src/main/java/org/teasoft/bee/osql/exception/BeeErrorGrammarException.java index a4b0d6e5ef3b3f10532d874fa4a76a7a841a7d11..608d78fe6c2968d00c0a3dc01688a0ad4d765c70 100644 --- a/src/main/java/org/teasoft/bee/osql/exception/BeeErrorGrammarException.java +++ b/src/main/java/org/teasoft/bee/osql/exception/BeeErrorGrammarException.java @@ -20,7 +20,7 @@ package org.teasoft.bee.osql.exception; import org.teasoft.bee.osql.BeeException; /** - * Bee错误语法异常.Bee Error Grammar Exception + * Bee Error Grammar Exception * @author Kingstar * @since 1.6 */ diff --git a/src/main/java/org/teasoft/bee/osql/exception/BeeErrorNameException.java b/src/main/java/org/teasoft/bee/osql/exception/BeeErrorNameException.java index 1ba5b5c0ad80e2022d5890d4d90fd005ea3bf712..b1e49185db7d0c07a0f0c1e91602db8e77b3d5ba 100644 --- a/src/main/java/org/teasoft/bee/osql/exception/BeeErrorNameException.java +++ b/src/main/java/org/teasoft/bee/osql/exception/BeeErrorNameException.java @@ -20,7 +20,7 @@ package org.teasoft.bee.osql.exception; import org.teasoft.bee.osql.BeeException; /** - * 变量名命名异常.Bee error name exception. + * Bee error name exception. * @author Kingstar * @since 1.9.8 */ diff --git a/src/main/java/org/teasoft/bee/osql/exception/BeeIllegalAccessException.java b/src/main/java/org/teasoft/bee/osql/exception/BeeIllegalAccessException.java index 4b7df003d8439847e577979b617117bef6460784..5ed2bb9551bb0ffd1a0cafdf190d0e34e597ac0c 100644 --- a/src/main/java/org/teasoft/bee/osql/exception/BeeIllegalAccessException.java +++ b/src/main/java/org/teasoft/bee/osql/exception/BeeIllegalAccessException.java @@ -20,7 +20,7 @@ package org.teasoft.bee.osql.exception; import org.teasoft.bee.osql.BeeException; /** - * 与java.lang.IllegalAccessException对应的异常.Define for java.lang.IllegalAccessException. + * Define for java.lang.IllegalAccessException. * @author Kingstar * @since 1.4 */ diff --git a/src/main/java/org/teasoft/bee/osql/exception/BeeIllegalBusinessException.java b/src/main/java/org/teasoft/bee/osql/exception/BeeIllegalBusinessException.java index 7435fe2f9cf2cff1de5a989b12d583c56e69a384..703f5634d9a2d4e03b07c6dbd4584605485205ab 100644 --- a/src/main/java/org/teasoft/bee/osql/exception/BeeIllegalBusinessException.java +++ b/src/main/java/org/teasoft/bee/osql/exception/BeeIllegalBusinessException.java @@ -20,7 +20,7 @@ package org.teasoft.bee.osql.exception; import org.teasoft.bee.osql.BeeException; /** - * 非法业务异常.Illegal business Exception. + * Illegal business Exception. * @author Kingstar * @since 1.7.2 */ diff --git a/src/main/java/org/teasoft/bee/osql/exception/BeeIllegalEntityException.java b/src/main/java/org/teasoft/bee/osql/exception/BeeIllegalEntityException.java index fb5c0d75dbba57109e4e5ba4b369c624e4b7932a..31aa822decafff6857b2853e99caf0986fbc4313 100644 --- a/src/main/java/org/teasoft/bee/osql/exception/BeeIllegalEntityException.java +++ b/src/main/java/org/teasoft/bee/osql/exception/BeeIllegalEntityException.java @@ -20,7 +20,7 @@ package org.teasoft.bee.osql.exception; import org.teasoft.bee.osql.BeeException; /** - * 非法的Bee实体异常.Bee illegal entity exception. + * Bee illegal entity exception. * @author Kingstar * @since 1.5 */ diff --git a/src/main/java/org/teasoft/bee/osql/exception/BeeIllegalParameterException.java b/src/main/java/org/teasoft/bee/osql/exception/BeeIllegalParameterException.java index d8a0d913b4432f82a56cc8cdba7b1a74e620a442..977357a85aa78d742a3f9c9e9f1fb2918462105d 100644 --- a/src/main/java/org/teasoft/bee/osql/exception/BeeIllegalParameterException.java +++ b/src/main/java/org/teasoft/bee/osql/exception/BeeIllegalParameterException.java @@ -20,7 +20,7 @@ package org.teasoft.bee.osql.exception; import org.teasoft.bee.osql.BeeException; /** - * 非法的Bee参数异常.Bee illegal parameter exception. + * Bee illegal parameter exception. * @author Kingstar * @since 1.5 */ diff --git a/src/main/java/org/teasoft/bee/osql/exception/BeeIllegalSQLException.java b/src/main/java/org/teasoft/bee/osql/exception/BeeIllegalSQLException.java index 40ef6e42ea85c82716d3bdf85f2e82ab94f4b997..e487d78be2318774f01bff2d279a748034404341 100644 --- a/src/main/java/org/teasoft/bee/osql/exception/BeeIllegalSQLException.java +++ b/src/main/java/org/teasoft/bee/osql/exception/BeeIllegalSQLException.java @@ -20,7 +20,7 @@ package org.teasoft.bee.osql.exception; import org.teasoft.bee.osql.BeeException; /** - * 非法的Bee SQL异常.Bee Illegal SQLException + * Bee Illegal SQLException * @author Kingstar * @since 1.9.8 */ diff --git a/src/main/java/org/teasoft/bee/osql/exception/BeeInstantiationException.java b/src/main/java/org/teasoft/bee/osql/exception/BeeInstantiationException.java index ba292a4a83644e40abed11d4ca7e7fb5872cd245..979f793016eec440841317ac75981146abc76dab 100644 --- a/src/main/java/org/teasoft/bee/osql/exception/BeeInstantiationException.java +++ b/src/main/java/org/teasoft/bee/osql/exception/BeeInstantiationException.java @@ -20,7 +20,7 @@ package org.teasoft.bee.osql.exception; import org.teasoft.bee.osql.BeeException; /** - * 与java.lang.InstantiationException对应的异常. Define for java.lang.InstantiationException. + * Define for java.lang.InstantiationException. * @author Kingstar * @since 1.4 */ diff --git a/src/main/java/org/teasoft/bee/osql/exception/ConfigWrongException.java b/src/main/java/org/teasoft/bee/osql/exception/ConfigWrongException.java index 639281f287e66887c191981a2fb47f89bc8b9563..44a4480eef066b7673e038632b8dcef91da82ecf 100644 --- a/src/main/java/org/teasoft/bee/osql/exception/ConfigWrongException.java +++ b/src/main/java/org/teasoft/bee/osql/exception/ConfigWrongException.java @@ -20,7 +20,7 @@ package org.teasoft.bee.osql.exception; import org.teasoft.bee.osql.BeeException; /** - * 配置信息错误异常.Config wrong exception. + * Config wrong exception. * @author Kingstar * @since 1.8 */ diff --git a/src/main/java/org/teasoft/bee/osql/exception/JoinTableException.java b/src/main/java/org/teasoft/bee/osql/exception/JoinTableException.java index 963557e1d8c7b475d3bd246722c2571f3c39512f..f8f59469c675cedc9cd6a47fa03af164815396f8 100644 --- a/src/main/java/org/teasoft/bee/osql/exception/JoinTableException.java +++ b/src/main/java/org/teasoft/bee/osql/exception/JoinTableException.java @@ -20,7 +20,7 @@ package org.teasoft.bee.osql.exception; import org.teasoft.bee.osql.BeeException; /** - * 表连接异常.Join table exception. + * Join table exception. * @author Kingstar * @since 1.7 */ diff --git a/src/main/java/org/teasoft/bee/osql/exception/JoinTableParameterException.java b/src/main/java/org/teasoft/bee/osql/exception/JoinTableParameterException.java index 5869108c9bdac7ac4a791ee6db8e90e5c4934828..fb5b7736ab722e42c79f5f04c025df719c9d304c 100644 --- a/src/main/java/org/teasoft/bee/osql/exception/JoinTableParameterException.java +++ b/src/main/java/org/teasoft/bee/osql/exception/JoinTableParameterException.java @@ -20,7 +20,7 @@ package org.teasoft.bee.osql.exception; import org.teasoft.bee.osql.BeeException; /** - * 表连接参数异常.Join table parameter exception. + * Join table parameter exception. * @author Kingstar * @since 1.7 */ diff --git a/src/main/java/org/teasoft/bee/osql/exception/NoConfigException.java b/src/main/java/org/teasoft/bee/osql/exception/NoConfigException.java index 1cd107f2957eb0c2a6a4666d8bcabab5acea8d5c..dfcbc6a6b9254b7a692618e89180497e02f7fe6d 100644 --- a/src/main/java/org/teasoft/bee/osql/exception/NoConfigException.java +++ b/src/main/java/org/teasoft/bee/osql/exception/NoConfigException.java @@ -20,7 +20,7 @@ package org.teasoft.bee.osql.exception; import org.teasoft.bee.osql.BeeException; /** - * 没有配置信息异常.No config exception. + * No config exception. * @author Kingstar * @since 1.4 */ diff --git a/src/main/java/org/teasoft/bee/osql/exception/NotSupportedException.java b/src/main/java/org/teasoft/bee/osql/exception/NotSupportedException.java index 7ba843466850ccbb78c33f54af01d71d700fdfbb..4719cb5d7da8e9a1b7cc2d79fbb0ace5a840b7e6 100644 --- a/src/main/java/org/teasoft/bee/osql/exception/NotSupportedException.java +++ b/src/main/java/org/teasoft/bee/osql/exception/NotSupportedException.java @@ -20,7 +20,7 @@ package org.teasoft.bee.osql.exception; import org.teasoft.bee.osql.BeeException; /** - * 不支持功能的异常.Not Supported Exception. + * Not Supported Exception. * @author Kingstar * @since 1.8.15 */ diff --git a/src/main/java/org/teasoft/bee/osql/exception/SqlNullException.java b/src/main/java/org/teasoft/bee/osql/exception/SqlNullException.java index f7745093567c0f498b9043c15b47470e8d45603b..7d40503ce5f28366c65662cd7ffacebdaa7cbde9 100644 --- a/src/main/java/org/teasoft/bee/osql/exception/SqlNullException.java +++ b/src/main/java/org/teasoft/bee/osql/exception/SqlNullException.java @@ -20,7 +20,7 @@ package org.teasoft.bee.osql.exception; import org.teasoft.bee.osql.BeeException; /** - * Sql语句是null的异常.Exception of sql statement string is null. + * Exception of sql statement string is null. * @author Kingstar * @since 1.6 */ diff --git a/src/main/java/org/teasoft/bee/osql/interccept/Interceptor.java b/src/main/java/org/teasoft/bee/osql/interccept/Interceptor.java new file mode 100644 index 0000000000000000000000000000000000000000..142df1aee18852f2a20d2f5ed981c5fbb1af4796 --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/interccept/Interceptor.java @@ -0,0 +1,90 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql.interccept; + +import java.util.List; + +import org.teasoft.bee.osql.SuidType; + +/** + * Interceptor. + * order:1.beforePasreEntity->2.afterCompleteSql->3.beforeReturn + * @author Kingstar + * @since 1.11 + */ +public interface Interceptor { + + /** + * call before parsing entity into SQL + * @param entity + * @param suidType + * @return Processed entity + */ + public Object beforePasreEntity(Object entity,SuidType suidType); + + /** + * call before parsing entity array into SQL + * @param entityArray entity array + * @param suidType SuidType + * @return entityArray Processed entity array + */ + public Object[] beforePasreEntity(Object entityArray[],SuidType suidType); + + /** + * set OneTime temporary dataSource name. + * When there are multiple dataSource, specifying the name of a dataSource is effective. + * @param ds OneTime temporary dataSource name + */ + public void setDataSourceOneTime(String ds); + + /** + * Get OneTime temporary dataSource name + * @return OneTime temporary dataSource name + */ + public String getOneTimeDataSource(); + + + public void setTabNameOneTime(String tabName); + public void setTabSuffixOneTime(String tabSuffix); + + public String getOneTimeTabName(); + public String getOneTimeTabSuffix(); + + + /** + * call after finished to SQL + * @param sql + * @return Processed sql string + */ + public String afterCompleteSql(String sql); + + /** + * call after accessing the DB and getting the structured data. + *
it is used for the query that returns the Javabean structure. + * @param list query result with List type + */ + @SuppressWarnings("rawtypes") + public void beforeReturn(List list); + + /** + * call after accessing the DB and getting the processing results. + *
it is used for update, insert, delete and query methods that do not return the Javabean structure. + */ + public void beforeReturn(); + +} diff --git a/src/main/java/org/teasoft/bee/osql/interccept/InterceptorChain.java b/src/main/java/org/teasoft/bee/osql/interccept/InterceptorChain.java new file mode 100644 index 0000000000000000000000000000000000000000..d82b956de644f13bf7c6559c1b0b97f996e7b223 --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/interccept/InterceptorChain.java @@ -0,0 +1,33 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql.interccept; + +/** + * Interceptor Chain + * @author Kingstar + * @since 1.11 + */ +public interface InterceptorChain extends Interceptor { + + /** + * add Interceptor to chain + * @param interceptor Interceptor + */ + public void addInterceptor(Interceptor interceptor); + +} diff --git a/src/main/java/org/teasoft/bee/osql/search/Operator.java b/src/main/java/org/teasoft/bee/osql/search/Operator.java index d2078ba93e784cc5c4842557af33f582f6417748..41172bf77eb6cc9e38c21748dac5a6e1ae1b6f9c 100644 --- a/src/main/java/org/teasoft/bee/osql/search/Operator.java +++ b/src/main/java/org/teasoft/bee/osql/search/Operator.java @@ -18,8 +18,7 @@ package org.teasoft.bee.osql.search; /** - * 较全的操作符 - * More complete operators + * More comprehensive operators. * @author Kingstar * @since 1.9.8 */ diff --git a/src/main/java/org/teasoft/bee/osql/search/Search.java b/src/main/java/org/teasoft/bee/osql/search/Search.java index 99b948996a646de24d517c9668a39ff8badf964b..918102e1898822f0368bcf62ab5567cfe4e763b5 100644 --- a/src/main/java/org/teasoft/bee/osql/search/Search.java +++ b/src/main/java/org/teasoft/bee/osql/search/Search.java @@ -18,31 +18,31 @@ package org.teasoft.bee.osql.search; /** - * 为了过滤查询记录的结构体.Struct for search the record. + * Struct for search the record. *

* eg: * new Search("id",Operator.between,"100030","100035","or"); - * --> or id between 100030 and 100035 - + *
--> or id between 100030 and 100035 + * * @author Kingstar * @since 1.9.8 */ public class Search { - + private String field; private Operator op; private String value1; - + // when like,notLike, value2 is:Left,Right,LeftRight // when function, value2 is: alias name //between, notBetween value2 is:second para // other Operator,value2 is null - private String value2; - + private String value2; + private String op2; //or , and is default - + public Search() {} - + public Search(String field, Operator operator, String value1, String value2) { super(); this.field = field; @@ -63,24 +63,27 @@ public class Search { public String getField() { return field; } + public void setField(String field) { this.field = field; } + public Operator getOp() { return op; } + public void setOp(Operator operator) { this.op = operator; } - + public String getValue1() { return value1; } - + public void setValue1(String value1) { this.value1 = value1; } - + /** * when like,notLike, value2 is:Left,Right,LeftRight * when function, value2 is: alias name @@ -91,7 +94,7 @@ public class Search { public String getValue2() { return value2; } - + /** * when like,notLike, value2 is:Left,Right,LeftRight * when function, value2 is: alias name @@ -102,7 +105,7 @@ public class Search { public void setValue2(String value2) { this.value2 = value2; } - + /** * it will be : "or", "and" , "(" , ")" , "or (", ") or", "and (", ") and" * @return operator2 @@ -110,7 +113,7 @@ public class Search { public String getOp2() { return op2; } - + /** * it will be : "or", "and" , "(" , ")" , "or (", ") or", "and (", ") and" * @param operator2 @@ -118,5 +121,5 @@ public class Search { public void setOp2(String operator2) { this.op2 = operator2; } - + } diff --git a/src/main/java/org/teasoft/bee/osql/service/ObjSQLAbstractServiceImpl.java b/src/main/java/org/teasoft/bee/osql/service/ObjSQLAbstractServiceImpl.java index a5edaf247085971047788d340f262303e2999616..33a3d87252341845b7e34530872b64f117778d49 100644 --- a/src/main/java/org/teasoft/bee/osql/service/ObjSQLAbstractServiceImpl.java +++ b/src/main/java/org/teasoft/bee/osql/service/ObjSQLAbstractServiceImpl.java @@ -20,10 +20,12 @@ package org.teasoft.bee.osql.service; import java.util.List; import org.teasoft.bee.osql.Condition; +import org.teasoft.bee.osql.NameTranslate; import org.teasoft.bee.osql.Suid; +import org.teasoft.bee.osql.interccept.InterceptorChain; /** - * 默认抽象通用面向对象SQL服务实现类.Default common abstract object SQLService implement class. + * Default common abstract object SQLService implement class. * @author Kingstar * @since 1.0 */ @@ -90,5 +92,29 @@ public abstract class ObjSQLAbstractServiceImpl implements ObjSQLService { //Add the business logic if need. getSuid().endSameConnection(); } + + @Override + public void setDataSourceName(String dsName) { + //Add the business logic if need. + getSuid().setDataSourceName(dsName); + } + + @Override + public String getDataSourceName() { + //Add the business logic if need. + return getSuid().getDataSourceName(); + } + + @Override + public InterceptorChain getInterceptorChain() { + //Add the business logic if need. + return getSuid().getInterceptorChain(); + } + + @Override + public void setNameTranslate(NameTranslate nameTranslate) { + //Add the business logic if need. + getSuid().setNameTranslate(nameTranslate); + } } diff --git a/src/main/java/org/teasoft/bee/osql/service/ObjSQLRichAbstractServiceImpl.java b/src/main/java/org/teasoft/bee/osql/service/ObjSQLRichAbstractServiceImpl.java index 79e3b835e20846cce1fd78ebbb6b0971df6e14ca..86d675a8262e83a9f8920d24a905f3dcded7100a 100644 --- a/src/main/java/org/teasoft/bee/osql/service/ObjSQLRichAbstractServiceImpl.java +++ b/src/main/java/org/teasoft/bee/osql/service/ObjSQLRichAbstractServiceImpl.java @@ -26,7 +26,7 @@ import org.teasoft.bee.osql.OrderType; import org.teasoft.bee.osql.SuidRich; /** - * 默认抽象通用丰富的面向对象SQL服务实现类.Default common abstract object rich SQLService implement class. + * Default common abstract object rich SQLService implement class. * @author Kingstar * @since 1.0 */ @@ -167,7 +167,7 @@ public abstract class ObjSQLRichAbstractServiceImpl extends ObjSQLAbstractServic } @Override - public List selectString(T entity, String selectFields) { + public List selectString(T entity, String... selectFields) { //Add the business logic if need. return getSuidRich().selectString(entity, selectFields); } @@ -347,5 +347,11 @@ public abstract class ObjSQLRichAbstractServiceImpl extends ObjSQLAbstractServic //Add the business logic if need. return getSuidRich().save(entity); } + + @Override + public long insertAndReturnId(T entity, IncludeType includeType) { + //Add the business logic if need. + return getSuidRich().insertAndReturnId(entity, includeType); + } } diff --git a/src/main/java/org/teasoft/bee/osql/service/ObjSQLRichService.java b/src/main/java/org/teasoft/bee/osql/service/ObjSQLRichService.java index f2086ce4d82e8cc96ba762e74cecdd5a821d66e5..16a62229d7e0313c0edbae9f810618f3ed13058c 100644 --- a/src/main/java/org/teasoft/bee/osql/service/ObjSQLRichService.java +++ b/src/main/java/org/teasoft/bee/osql/service/ObjSQLRichService.java @@ -20,7 +20,7 @@ package org.teasoft.bee.osql.service; import org.teasoft.bee.osql.SuidRich; /** - * 默认通用丰富的面向对象SQL服务接口.Default common object rich SQLService. + * Default common object rich SQLService. * @author Kingstar * @since 1.0 */ diff --git a/src/main/java/org/teasoft/bee/osql/service/ObjSQLService.java b/src/main/java/org/teasoft/bee/osql/service/ObjSQLService.java index d3f72b86b603e3165cd38bca64e318568d3b0bca..7f502f9ced05a14802a9042e0a9536e5728a617c 100644 --- a/src/main/java/org/teasoft/bee/osql/service/ObjSQLService.java +++ b/src/main/java/org/teasoft/bee/osql/service/ObjSQLService.java @@ -20,7 +20,7 @@ package org.teasoft.bee.osql.service; import org.teasoft.bee.osql.Suid; /** - * 默认通用面向对象SQL服务接口.Default common object SQLService. + * Default common object SQLService. * @author Kingstar * @since 1.0 */ diff --git a/src/main/java/org/teasoft/bee/osql/token/CustomAutoSqlToken.java b/src/main/java/org/teasoft/bee/osql/token/CustomAutoSqlToken.java new file mode 100644 index 0000000000000000000000000000000000000000..cc0da3c1de8b2d530872a99ae8dfe084cd181220 --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/token/CustomAutoSqlToken.java @@ -0,0 +1,53 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * The license,see the LICENSE file. + */ + +package org.teasoft.bee.osql.token; + +/** + * Custom auto SQL token. + * do not effect in batch insert. + * @author Kingstar + * @since 1.11 + */ +public final class CustomAutoSqlToken { + + /** + * the para is not null,will transfer. + * eg: + * userid in #{userid@in} + * if value of userid is not null, will parse "userid in #{userid@in}" + */ + public static final String isNotNull = ""; + + /** + * if value of para is not null and not empty string,will transfer. + */ + public static final String isNotBlank = ""; + + public static final String endIf = ""; + + /** + * support list and set, transfer to: in (1,2) or in ('a','b') + * userid in #{userid @in} + * userid in #{userid@in} + */ + public static final String atIn="@in"; + + /** + * when the value is null, name=#{name@toIsNULL1} -> name is null (delete one char '=' + */ + public static final String toIsNULL1="@toIsNULL1"; + + /** + * when the value is null, num>=#{num@toIsNULL2} -> name is null (delete two char '>=') + */ + public static final String toIsNULL2="@toIsNULL2"; + + /** + * just use in like + */ + public static final String percent ="%"; +} diff --git a/src/main/java/org/teasoft/bee/osql/transaction/Transaction.java b/src/main/java/org/teasoft/bee/osql/transaction/Transaction.java index 6835f1d243ef4b629a6c99946eb05bb5a0c7b731..1d736a3ff51a9ffa9047fe288b5bb0a39123bd92 100644 --- a/src/main/java/org/teasoft/bee/osql/transaction/Transaction.java +++ b/src/main/java/org/teasoft/bee/osql/transaction/Transaction.java @@ -18,7 +18,7 @@ package org.teasoft.bee.osql.transaction; /** - * 事务接口.Transaction interface. + * Transaction interface. * @author Kingstar * @since 1.0 */ diff --git a/src/main/java/org/teasoft/bee/osql/transaction/TransactionIsolationLevel.java b/src/main/java/org/teasoft/bee/osql/transaction/TransactionIsolationLevel.java index 937c88ca4542878f48291825f356f49407524de0..80d19560cb66d3ecbafbe0d99494c0ce3e33a110 100644 --- a/src/main/java/org/teasoft/bee/osql/transaction/TransactionIsolationLevel.java +++ b/src/main/java/org/teasoft/bee/osql/transaction/TransactionIsolationLevel.java @@ -18,56 +18,53 @@ package org.teasoft.bee.osql.transaction; /** - * 事务隔离级别.Transaction isolation level. + * Transaction isolation level. * @author Kingstar * @since 1.0 */ public enum TransactionIsolationLevel { /** - * 指示事务不受支持的常量.A constant indicating that transactions are not supported. + * A constant indicating that transactions are not supported. */ TRANSACTION_NONE(0), /** - * 指示可以发生:脏读 (dirty read)、不可重复读和虚读 (phantom read) 的常量
* A constant indicating that dirty reads, non-repeatable reads and phantom reads can occur. - * This level allows a row changed by one transaction to be read - * by another transaction before any changes in that row have been - * committed (a "dirty read"). If any of the changes are rolled back, - * the second transaction will have retrieved an invalid row. + *
This level allows a row changed by one transaction to be read + *
by another transaction before any changes in that row have been + *
committed (a "dirty read"). If any of the changes are rolled back, + *
the second transaction will have retrieved an invalid row. */ TRANSACTION_READ_UNCOMMITTED(1), /** - * 指示不可以发生脏读的常量;不可重复读和虚读可以发生
A constant indicating that - * dirty reads are prevented; non-repeatable reads and phantom reads can occur. - * This level only prohibits a transaction - * from reading a row with uncommitted changes in it. + * A constant indicating that dirty reads are prevented; + *
non-repeatable reads and phantom reads can occur. + *
This level only prohibits a transaction + *
from reading a row with uncommitted changes in it. */ TRANSACTION_READ_COMMITTED(2), /** - * 指示不可以发生脏读和不可重复读的常量;虚读可以发生
* A constant indicating that dirty reads and non-repeatable reads are prevented; phantom reads can occur. - * This level prohibits a transaction from - * reading a row with uncommitted changes in it, and it also - * prohibits the situation where one transaction reads a row, - * a second transaction alters the row, and the first transaction - * rereads the row, getting different values the second time - * (a "non-repeatable read"). + *
This level prohibits a transaction from + *
reading a row with uncommitted changes in it, and it also + *
prohibits the situation where one transaction reads a row, + *
a second transaction alters the row, and the first transaction + *
rereads the row, getting different values the second time + *
(a "non-repeatable read"). */ TRANSACTION_REPEATABLE_READ(4), /** - * 指示不可以发生脏读、不可重复读和虚读的常量
A constant indicating that - * dirty reads, non-repeatable reads and phantom reads are prevented. - * This level includes the prohibitions in - * TRANSACTION_REPEATABLE_READ and further prohibits the - * situation where one transaction reads all rows that satisfy - * a WHERE condition, a second transaction inserts a row that - * satisfies that WHERE condition, and the first transaction - * rereads for the same condition, retrieving the additional - * "phantom" row in the second read. + * A constant indicating that dirty reads, non-repeatable reads and phantom reads are prevented. + *
This level includes the prohibitions in + *
TRANSACTION_REPEATABLE_READ and further prohibits the + *
situation where one transaction reads all rows that satisfy + *
a WHERE condition, a second transaction inserts a row that + *
satisfies that WHERE condition, and the first transaction + *
rereads for the same condition, retrieving the additional + *
"phantom" row in the second read. */ TRANSACTION_SERIALIZABLE(8); @@ -78,8 +75,8 @@ public enum TransactionIsolationLevel } /** - * 获取隔离级别.get the value of TransactionIsolationLevel. - * @return 隔离级别的值.value of TransactionIsolationLevel. + * get the value of TransactionIsolationLevel. + * @return value of TransactionIsolationLevel. */ public int getLevel() { return this.level; diff --git a/src/main/java/org/teasoft/bee/osql/type/SetParaTypeConvert.java b/src/main/java/org/teasoft/bee/osql/type/SetParaTypeConvert.java new file mode 100644 index 0000000000000000000000000000000000000000..0ced261acae4759d452b89ab88499833e4216f8e --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/type/SetParaTypeConvert.java @@ -0,0 +1,30 @@ +/* + * Copyright 2020-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql.type; + +/** + * Convert the set-parameter type. + * The SetParaTypeConvert work for setting parameter to PreparedStatement. + * @author Kingstar + * @since 1.11 + */ +public interface SetParaTypeConvert { + + public Object convert(T value); + +} diff --git a/src/main/java/org/teasoft/bee/osql/type/TypeHandler.java b/src/main/java/org/teasoft/bee/osql/type/TypeHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..c0f796cceb425ecc44274242490b2edf165613a9 --- /dev/null +++ b/src/main/java/org/teasoft/bee/osql/type/TypeHandler.java @@ -0,0 +1,39 @@ +/* + * Copyright 2020-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.teasoft.bee.osql.type; + +/** + * The TypeHandler work for handle ResultSet by select. + *
According to the field type of the entity, the processor is + *
selected to process the returned results of the query. + *
if use, need to open the openFieldTypeHandler configuration + * @author Kingstar + * @since 1.11 + */ +public interface TypeHandler { + + /** + * Use the custom field type processor to process the returned results of the query. + * @param fieldType Javabean field type. + * @param result get from ResultSet. + * @return processed result. + */ + public T process(final Class fieldType, final Object result); + + +} diff --git a/src/main/java/org/teasoft/bee/spi/PreLoad.java b/src/main/java/org/teasoft/bee/spi/PreLoad.java new file mode 100644 index 0000000000000000000000000000000000000000..6bd55a50f7881a390f121477ff2f3e13f9cd00b8 --- /dev/null +++ b/src/main/java/org/teasoft/bee/spi/PreLoad.java @@ -0,0 +1,16 @@ +/* + * Copyright 2016-2022 the original author.All rights reserved. + * Kingstar(honeysoft@126.com) + * The license,see the LICENSE file. + */ + +package org.teasoft.bee.spi; + +/** + * SPI Interface for Preload relevant basic information in advance. + * @author Kingstar + * @since 1.11 + */ +public interface PreLoad { + +} diff --git a/src/test/java/org/teasoft/bee/BeeExam.java b/src/test/java/org/teasoft/bee/BeeExam.java index 91c54337e6d32dc0509d19dbf91d765012d73405..49a96e18b7c32d0e0ecc09715ff843667f03e194 100644 --- a/src/test/java/org/teasoft/bee/BeeExam.java +++ b/src/test/java/org/teasoft/bee/BeeExam.java @@ -14,15 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.teasoft.bee; +//package org.teasoft.bee; -import org.junit.Assert; -import org.junit.Test; +//import org.junit.Assert; +//import org.junit.Test; /** * @author Kingstar * @since 1.7.2 */ +/* public class BeeExam { @Test @@ -64,6 +65,58 @@ public class BeeExam { isFinished=true; Assert.assertEquals(isFinished,true); +// V1.11 +// 2022-03-10 (yyyy-MM-dd) +// Instructions Counters +// Element Coverage +// Bee 94.5% +// Honey 73.3% +// +// Method Counters +// Element Coverage +// Bee 90.5% +// Honey 81.5% +// +// Line Counters +// Element Coverage +// Bee 92.6% +// Honey 75.7% + + +// V1.11 +// 2022-03-10 (yyyy-MM-dd) +// Instructions Counters +// Element Coverage +// Bee 96.1% +// Honey 75.3% +// +// Method Counters +// Element Coverage +// Bee 92.2% +// Honey 83.6% +// +// Type Counters +// Element Coverage +// Bee 92.3% +// Honey 95.9% + +// V1.11 +// 2022-03-02 (yyyy-MM-dd) +// Instructions Counters +// Element Coverage +// Bee 95.5% +// Honey 75.1% +// +// Method Counters +// Element Coverage +// Bee 91.4% +// Honey 81.9% +// +// Type Counters +// Element Coverage +// Bee 92.5% +// Honey 96.5% + // V1.9.8 // 2021-10-22 (yyyy-MM-dd) @@ -200,5 +253,44 @@ public class BeeExam { // bee-exam(v1.9)2021-05-02 02.54.55.328-normal(Microsoft SQL Server).txt // bee-exam(v1.9)2021-05-02 02.55.16.45-cache(MySQL).txt +// test for 1.9.8 +// bee-exam(v1.9.8)2021-10-22 13.28.59.122-normal(MySQL).txt +// bee-exam(v1.9.8)2021-10-22 13.29.18.02-normal(Oracle).txt +// bee-exam(v1.9.8)2021-10-22 13.29.41.620-normal(SQLite).txt +// bee-exam(v1.9.8)2021-10-22 13.30.00.709-normal(H2).txt +// bee-exam(v1.9.8)2021-10-22 13.30.07.72-normal(PostgreSQL).txt +// bee-exam(v1.9.8)2021-10-22 13.30.26.941-normal(Microsoft SQL Server).txt +// bee-exam(v1.9.8)2021-10-22 13.30.36.536-normal(MySQL).txt +// bee-exam(v1.9.8)2021-10-22 13.30.58.799-cache(MySQL).txt + +// test for 1.11 +// bee-exam(v1.11)2022-03-02 11.12.43.273-normal(MySQL).txt +// bee-exam(v1.11)2022-03-02 11.13.02.887-normal(Oracle).txt +// bee-exam(v1.11)2022-03-02 11.13.31.975-normal(SQLite).txt +// bee-exam(v1.11)2022-03-02 11.13.52.112-normal(H2).txt +// bee-exam(v1.11)2022-03-02 11.13.58.850-normal(PostgreSQL).txt +// bee-exam(v1.11)2022-03-02 11.14.12.619-normal(Microsoft SQL Server).txt +// bee-exam(v1.11)2022-03-02 11.14.21.41-normal(MySQL).txt +// bee-exam(v1.11)2022-03-02 11.14.45.538-cache(MySQL).txt + +// bee-exam(v1.11)2022-03-10 11.43.30.334-cache(MySQL).txt +// bee-exam(v1.11)2022-03-10 11.43.12.658-normal(MySQL).txt +// bee-exam(v1.11)2022-03-10 11.43.05.81-normal(Microsoft SQL Server).txt +// bee-exam(v1.11)2022-03-10 11.42.48.444-normal(PostgreSQL).txt +// bee-exam(v1.11)2022-03-10 11.42.41.610-normal(H2).txt +// bee-exam(v1.11)2022-03-10 11.42.19.602-normal(SQLite).txt +// bee-exam(v1.11)2022-03-10 11.41.53.808-normal(Oracle).txt +// bee-exam(v1.11)2022-03-10 11.41.36.406-normal(MySQL).txt + +// bee-exam(v1.11)2022-04-30 23.46.56.119-normal(MySQL).txt +// bee-exam(v1.11)2022-04-30 23.47.10.441-normal(Oracle).txt +// bee-exam(v1.11)2022-04-30 23.47.36.960-normal(SQLite).txt +// bee-exam(v1.11)2022-04-30 23.48.00.55-normal(H2).txt +// bee-exam(v1.11)2022-04-30 23.48.05.650-normal(PostgreSQL).txt +// bee-exam(v1.11)2022-04-30 23.48.20.833-normal(Microsoft SQL Server).txt +// bee-exam(v1.11)2022-04-30 23.48.30.571-normal(MySQL).txt +// bee-exam(v1.11)2022-04-30 23.48.50.542-cache(MySQL).txt + } } +*/ diff --git a/src/test/java/org/teasoft/bee/change-log.txt b/src/test/java/org/teasoft/bee/change-log.txt index 39a132a59b13595745c6f615a06f5eb42b42fafb..4cff0d1174725a1ef3117a51c84ca0ea498b55c2 100644 --- a/src/test/java/org/teasoft/bee/change-log.txt +++ b/src/test/java/org/teasoft/bee/change-log.txt @@ -132,3 +132,23 @@ bee-exam(v1.9.8)2021-10-22 13.30.07.72-normal(PostgreSQL).txt bee-exam(v1.9.8)2021-10-22 13.30.26.941-normal(Microsoft SQL Server).txt bee-exam(v1.9.8)2021-10-22 13.30.36.536-normal(MySQL).txt bee-exam(v1.9.8)2021-10-22 13.30.58.799-cache(MySQL).txt + +bee-exam(v1.11)2022-03-10 11.43.30.334-cache(MySQL).txt +bee-exam(v1.11)2022-03-10 11.43.12.658-normal(MySQL).txt +bee-exam(v1.11)2022-03-10 11.43.05.81-normal(Microsoft SQL Server).txt +bee-exam(v1.11)2022-03-10 11.42.48.444-normal(PostgreSQL).txt +bee-exam(v1.11)2022-03-10 11.42.41.610-normal(H2).txt +bee-exam(v1.11)2022-03-10 11.42.19.602-normal(SQLite).txt +bee-exam(v1.11)2022-03-10 11.41.53.808-normal(Oracle).txt +bee-exam(v1.11)2022-03-10 11.41.36.406-normal(MySQL).txt + +bee-exam(v1.11)2022-04-30 23.46.56.119-normal(MySQL).txt +bee-exam(v1.11)2022-04-30 23.47.10.441-normal(Oracle).txt +bee-exam(v1.11)2022-04-30 23.47.36.960-normal(SQLite).txt +bee-exam(v1.11)2022-04-30 23.48.00.55-normal(H2).txt +bee-exam(v1.11)2022-04-30 23.48.05.650-normal(PostgreSQL).txt +bee-exam(v1.11)2022-04-30 23.48.20.833-normal(Microsoft SQL Server).txt +bee-exam(v1.11)2022-04-30 23.48.30.571-normal(MySQL).txt +bee-exam(v1.11)2022-04-30 23.48.50.542-cache(MySQL).txt + +