From 8ed50ab8445f07a9bbaf194f2c6276324be71b1c Mon Sep 17 00:00:00 2001 From: Kingstar Date: Fri, 26 Feb 2021 21:48:56 +0800 Subject: [PATCH 001/124] update --- FAQ_CN.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/FAQ_CN.md b/FAQ_CN.md index ed555bd..c4a735c 100644 --- a/FAQ_CN.md +++ b/FAQ_CN.md @@ -31,7 +31,7 @@ A: V1.8支持读写分离一主多从, 仅分库等多数据源模式。 4. -Q: 在一个DB中,随着数据量不断增长,需要将老的数据移到历史表中. 如,订单表orders,将5月,6月数据移到 orders\_202005,orders\_202006,结构与表orders一样。 如何用同一javabean,同时映射多个数据表? +Q: 在一个DB中,随着数据量不断增长,需要将老的数据移到历史表中. 如,订单表orders,将5月,6月数据移到 orders\_202005,orders\_202006,结构与表orders一样。 如何用同一Javabean,同时映射多个数据表? A: V1.8支持同库分表,动态表名映射.  @@ -183,7 +183,7 @@ https://my.oschina.net/u/4111850/blog/4944468 19. -Q: 没有与表对应的实体javabean,如何操作数据? +Q: 没有与表对应的实体Javabean,如何操作数据? A: 用map进行转换实体信息,查询/删除数据库中的数据. 参考bee-exam项目里: MapSuidExam @@ -224,8 +224,8 @@ MapSuidExam Q:表对应的实体Javabean有些字段不想解析,如何实现? A: -Ignore注解,忽略javabean字段,不进行转换. -但这种应尽量少用. 纯的javabean,当DB有变动时,很容易就可以更改了,自动生成纯Javabean更方便,安全. +Ignore注解,忽略Javabean字段,不进行转换. +但这种应尽量少用. 纯的Javabean,当DB有变动时,很容易就可以更改了,自动生成纯Javabean更方便,安全. Bee默认是不处理为null或空字符的字段的,因此,操作DB前将其置空即可. 21. -- Gitee From 2f03df332da20dc2581e4eacfdf30b182b8ff345 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sat, 27 Feb 2021 22:29:55 +0800 Subject: [PATCH 002/124] update description --- README_CN.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README_CN.md b/README_CN.md index e3e8cd1..26e2c04 100644 --- a/README_CN.md +++ b/README_CN.md @@ -31,14 +31,14 @@ jdk1.7+ * 5.**动态/任意组合**查询条件,不需要提前准备dao接口,有新的查询需求也不用修改或添加接口。 * 6.支持原生SQL排序, **原生语句分页**(不需要将全部数据查出来)。 * 7.支持直接返回**Json**格式查询结果; 链式编程。 -* 8.支持**存储过程**,支持原生SQL(**自定义sql**语句),支持**事务**、**for update**,支持**批处理**操作。 +* 8.支持**事务**、**for update**,支持**批处理**操作,支持原生SQL(**自定义sql**语句),支持**存储过程**。 * 9.支持**只查询一部分字段**。 * 10.支持面向对象方式复杂查询、**多表查询**(无n+1问题; 支持:一对一,一对多,多对一,多对多)。 * 11.**一级缓存**,概念简单,功能强大;一级缓存也可以**像JVM一样进行细粒度调优**;**智能缓存**,支持更新配置表,**不用重启**。 * 12.表名与实体名、字段名与属性名映射默认提供多种实现,且支持**自定义映射规则扩展**。 * 13.**多种DB**支持轻松扩展(MySQL,MariaDB,Oracle,H2,SQLite,PostgreSQL等直接可用)。 * 14.**无**第三方插件依赖;可零配置使用。 -* 15.提供表对应的javabean**自动生成工具**,Javaweb**后端代码**根据**模板自动生成**;能打印非占位符的**可执行sql**,方便调试。 +* 15.提供表对应的Javabean**自动生成工具**,Javaweb**后端代码**根据**模板自动生成**;能打印非占位符的**可执行sql**,方便调试。 * 16.支持**读写分离**一主多从, 仅**分库**等**多数据源**模式。 * 17.**分布式**环境下生成**连续单调递增**(在一个workerid内),**全局唯一**数字**id**;提供自然简单的分布式主键生成方式。 * 18.**支持同库分表,动态表名映射**。 @@ -63,7 +63,7 @@ SuidRich调整selectById方法且String类型参数的id智能识别Javabean的i 多表关联查询支持多个关联条件. 多个ORM操作使用同一个Connection. 支持长度大于0空字符串忽略处理,如"     ". -增加Ignore注解,忽略javabean字段,不进行转换. +增加Ignore注解,忽略Javabean字段,不进行转换. 用模板生成文件支持自定义起止标签. 完善DB连接管理. 加强代码质量. @@ -194,7 +194,7 @@ SuidRich调整selectById方法且String类型参数的id智能识别Javabean的i **Bee需要的文件** orm\compare\bee\service\BeeOrdersService.java -**Mybatis需要的文件** +**Mybatis需要的文件**(对一个表的操作,就会比Bee多三个dao相关文件) orm\compare\mybatis\service\MybatisOrdersService.java orm\compare\mybatis\dao\OrdersDao.java orm\compare\mybatis\dao\OrdersMapper.java -- Gitee From f4c52e34d430bec5feefedf95635802ca752f82a Mon Sep 17 00:00:00 2001 From: Kingstar Date: Mon, 1 Mar 2021 12:16:03 +0800 Subject: [PATCH 003/124] update description --- README_CN.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README_CN.md b/README_CN.md index 26e2c04..440bf5f 100644 --- a/README_CN.md +++ b/README_CN.md @@ -4,7 +4,7 @@ Bee #### 工欲善其事必先利其器!——《论语·卫灵公》 **Bee** 是一个简单,易用,功能强大,开发速度快,编码少的 JAVA ORM 框架。 -Bee简单易用:单表操作、多表关联操作,可以不用写sql,极少语句就可以完成SQL操作;10分钟即可学会使用。 +Bee简单易用:单表操作、多表关联操作,可以不用写sql,极少语句就可以完成SQL操作;**概念简单**,10分钟即可入门。 Bee功能强大:复杂查询也支持向对象方式,分页查询性能更高,一级缓存即可支持个性化优化;具有分布式特性。高级要求,还可以方便自定义SQL语句。 **如果说Mybatis在Hibernate之后不是重复造轮子,那Bee在Hibernate和Mybatis之后也不会是重复造轮子!** 择其优点,避其缺点,此外,还加有自己的优点! @@ -24,6 +24,7 @@ https://gitee.com/automvc/bee jdk1.7+ ## Bee主要功能特点介绍: +**Bee概念简单**(10分钟即可入门)、功能强大。 * 1.**接口简单,使用方便**。Suid接口中对应SQL语言的select,update,insert,delete操作提供**4个同名方法**。 * 2.使用了Bee,你可以不用再另外编写dao代码,直接调用Bee的api即可完成对DB的操作。 * 3.**约定优于配置**:Javabean没有注解,也不需要xml映射文件,只是纯的Javabean即可,甚至get,set方法不用也可以。 -- Gitee From 032bb306c3200dff124f1549b87da8eb14f29938 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 11 Mar 2021 07:53:49 +0800 Subject: [PATCH 004/124] rename --- src/main/java/org/teasoft/bee/osql/transaction/Transaction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d606643..6835f1d 100644 --- a/src/main/java/org/teasoft/bee/osql/transaction/Transaction.java +++ b/src/main/java/org/teasoft/bee/osql/transaction/Transaction.java @@ -29,7 +29,7 @@ public interface Transaction { public void rollback(); public void setReadOnly(boolean readOnly); - public void setTransactionIsolation(TransactionIsolationLevel level); + public void setTransactionIsolation(TransactionIsolationLevel transactionIsolationLevel); public boolean isReadOnly(); public int getTransactionIsolation(); -- Gitee From 04e30ae48c90194a0b0f2906da0b3ef5e1091c49 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 11 Mar 2021 07:54:19 +0800 Subject: [PATCH 005/124] support opWithField and setWithField in Condtion --- .../java/org/teasoft/bee/osql/Condition.java | 30 ++++++++++++++++--- .../teasoft/bee/osql/ConditionAssistant.java | 8 ++--- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/teasoft/bee/osql/Condition.java b/src/main/java/org/teasoft/bee/osql/Condition.java index ad8e71d..1a3ef33 100644 --- a/src/main/java/org/teasoft/bee/osql/Condition.java +++ b/src/main/java/org/teasoft/bee/osql/Condition.java @@ -62,6 +62,18 @@ public interface Condition extends ConditionAssistant { * @return Condition */ public Condition op(String field, Op Op, Object value); + + /** + * 添加一个表达式条件.Add a expression condition. + *
此方法不能用于SQL的update set. + * eg: opWithField(field1,Op.eq,field2)-->field1=field2 + * @param field1 + * @param Op 操作符.operator. + * @param field2 + * @return Condition + * @since 1.9 + */ + public Condition opWithField(String field1, Op Op, String field2); /** * 默认自动加 'and'.Default will automatically add 'and'. @@ -198,21 +210,21 @@ public interface Condition extends ConditionAssistant { * 设置需要更新的字段(仅用于SQL的update set),字段在自身基础上变化.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 fieldName + * @param otherFieldName * @return Condition * @since 1.8 */ - public Condition setAdd(String field, String fieldName); + 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. *
eg: setMultiply("price","delta")--> price=price*delta * @param field - * @param fieldName another fieldName + * @param otherFieldName other fieldName * @return Condition * @since 1.8 */ - public Condition setMultiply(String field, String fieldName); + public Condition setMultiply(String field, String otherFieldName); /** * 设置需要更新的字段(仅用于SQL的update set);当要更新的字段也需要用于where条件时,可用该方法 @@ -237,6 +249,16 @@ public interface Condition extends ConditionAssistant { public Condition set(String fieldNmae, String value); + /** + * set one field with other field value + * eg: setWithField(field1,field2)--> set field1=field2 + * @param field1 + * @param field2 + * @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. diff --git a/src/main/java/org/teasoft/bee/osql/ConditionAssistant.java b/src/main/java/org/teasoft/bee/osql/ConditionAssistant.java index 18817ce..dae5f92 100644 --- a/src/main/java/org/teasoft/bee/osql/ConditionAssistant.java +++ b/src/main/java/org/teasoft/bee/osql/ConditionAssistant.java @@ -28,10 +28,10 @@ import java.util.Set; public interface ConditionAssistant { /** - * Condition的FieldSet已包含的字段,默认情况不再遍历.If the field use in Condition,it would not be processed again in default. - * @return 返回用于Condition表达式的字段集合. + * Condition的whereField已包含的字段,默认情况不再遍历.If the field use in Condition,it would not be processed again in default. + * @return 返回用于where Condition表达式的字段集合. */ - public Set getFieldSet(); + public Set getWhereFields(); void setSuidType(SuidType SuidType); @@ -47,7 +47,7 @@ public interface ConditionAssistant { * @return set of fields * @since 1.7.2 */ - public Set getUpdatefieldSet(); + public Set getUpdatefields(); public String getSelectField(); -- Gitee From 8409124005350c6b607f13f3c09f5fdb13f2156e Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 11 Mar 2021 07:59:23 +0800 Subject: [PATCH 006/124] V1.9 Condition add method:opWithField,setWithField support like:field1=field2 --- README_CN.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README_CN.md b/README_CN.md index 440bf5f..c858e79 100644 --- a/README_CN.md +++ b/README_CN.md @@ -59,6 +59,7 @@ SuidRich调整selectById方法且String类型参数的id智能识别Javabean的i 加强聚合函数cont,sum,avg,min,max功能,Condition增加方法: public Condition selectFun(FunctionType functionType,String fieldForFun); public Condition selectFun(FunctionType functionType,String fieldForFun,String alias); +Condition 添加方法:opWithField,setWithField 支持像:field1=field2的表达式 无Javabean,用map承载需要转换的实体信息,操作数据库(查询,删除数据). 支持读取Excel(*.xls,*.xlsx),并将数据转成List,且导入到数据库(bee-ext). 多表关联查询支持多个关联条件. -- Gitee From 17c6a4f3465864663fdb419f19a68a29fa9941de Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 11 Mar 2021 08:01:11 +0800 Subject: [PATCH 007/124] V1.9 Condition add method:opWithField,setWithField support like :field1=field2 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b46b14b..84ede9d 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,7 @@ SuidRich adjust methods selectById for unique entity and intelligently judge the enhance aggregate function cont,sum,avg,min,max,Condition add method: public Condition selectFun(FunctionType functionType,String fieldForFun); public Condition selectFun(FunctionType functionType,String fieldForFun,String alias); +Condition add method:opWithField,setWithField support like :field1=field2 no Javabean, use map to set the entity information that needs to be transformed and operate the database(select/delete record). support read excel(*.xls,*.xlsx), converting data into List and importing them into database(bee-ext). more table join select support more join condition. -- Gitee From 4b01926d2f35df90cbf71df29c0af2e10fba8156 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 11 Mar 2021 08:34:15 +0800 Subject: [PATCH 008/124] update comment for Condition --- src/main/java/org/teasoft/bee/osql/Condition.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/teasoft/bee/osql/Condition.java b/src/main/java/org/teasoft/bee/osql/Condition.java index 1a3ef33..474da6e 100644 --- a/src/main/java/org/teasoft/bee/osql/Condition.java +++ b/src/main/java/org/teasoft/bee/osql/Condition.java @@ -67,9 +67,9 @@ public interface Condition extends ConditionAssistant { * 添加一个表达式条件.Add a expression condition. *
此方法不能用于SQL的update set. * eg: opWithField(field1,Op.eq,field2)-->field1=field2 - * @param field1 + * @param field1 first field * @param Op 操作符.operator. - * @param field2 + * @param field2 second field * @return Condition * @since 1.9 */ @@ -252,8 +252,8 @@ public interface Condition extends ConditionAssistant { /** * set one field with other field value * eg: setWithField(field1,field2)--> set field1=field2 - * @param field1 - * @param field2 + * @param field1 first field + * @param field2 second field * @return Condition * @since 1.9 */ -- Gitee From 8e7e8f9cdaa78666750d9169f9b197bba16d1f03 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 11 Mar 2021 08:39:12 +0800 Subject: [PATCH 009/124] update comment for Condition --- src/main/java/org/teasoft/bee/osql/Condition.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/teasoft/bee/osql/Condition.java b/src/main/java/org/teasoft/bee/osql/Condition.java index 474da6e..40bc3c5 100644 --- a/src/main/java/org/teasoft/bee/osql/Condition.java +++ b/src/main/java/org/teasoft/bee/osql/Condition.java @@ -230,23 +230,23 @@ public interface Condition extends ConditionAssistant { * 设置需要更新的字段(仅用于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 - * @param fieldNmae + * @param fieldName field name * @param num * @return Condition * @since 1.8 */ - public Condition set(String fieldNmae, Number num); + 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. *
eg: set("name", 'bee')-->name='bee' - * @param fieldNmae + * @param fieldName * @param value * @return Condition * @since 1.8 */ - public Condition set(String fieldNmae, String value); + public Condition set(String fieldName, String value); /** -- Gitee From 168f29d102e5b38d4031b46fb2141be871b7a854 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 11 Mar 2021 09:01:11 +0800 Subject: [PATCH 010/124] add test for V1.9 --- src/test/java/org/teasoft/bee/BeeExam.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/java/org/teasoft/bee/BeeExam.java b/src/test/java/org/teasoft/bee/BeeExam.java index 061d35c..adf2895 100644 --- a/src/test/java/org/teasoft/bee/BeeExam.java +++ b/src/test/java/org/teasoft/bee/BeeExam.java @@ -58,6 +58,9 @@ public class BeeExam { // bee-exam(v1.9)-normal(MySQL)-2021-01-17 23.52.19.330.txt // bee-exam(v1.9)-normal(MySQL)-2021-02-07 11.56.33.739.txt // bee-exam(v1.9)-normal(MySQL)-2021-02-14 10.11.34.561.txt +// bee-exam(v1.9)-normal(MySQL)-2021-03-11 08.47.40.114.txt +// bee-exam(v1.9)-cache-2021-03-11 08.52.07.423.txt + // 测试用例请查看工程:bee-exam // 以下任意一个地址: -- Gitee From 7597e3006fe34276ae57f0266b5d92e90ba348db Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 11 Mar 2021 09:01:17 +0800 Subject: [PATCH 011/124] add test for V1.9 --- src/test/java/org/teasoft/bee/change-log.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/org/teasoft/bee/change-log.txt b/src/test/java/org/teasoft/bee/change-log.txt index 1bbfa99..a839d73 100644 --- a/src/test/java/org/teasoft/bee/change-log.txt +++ b/src/test/java/org/teasoft/bee/change-log.txt @@ -73,3 +73,5 @@ bee-exam(v1.9)-normal(MySQL)-2020-12-29 14.59.21.09.txt bee-exam(v1.9)-normal(MySQL)-2021-01-17 23.52.19.330.txt bee-exam(v1.9)-normal(MySQL)-2021-02-07 11.56.33.739.txt bee-exam(v1.9)-normal(MySQL)-2021-02-14 10.11.34.561.txt +bee-exam(v1.9)-normal(MySQL)-2021-03-11 08.47.40.114.txt +bee-exam(v1.9)-cache-2021-03-11 08.52.07.423.txt -- Gitee From d3fa6a29e5db8bde955e9d5918234912f649c8cc Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sun, 14 Mar 2021 10:35:13 +0800 Subject: [PATCH 012/124] update the example of conditon --- src/main/java/org/teasoft/bee/osql/Condition.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/teasoft/bee/osql/Condition.java b/src/main/java/org/teasoft/bee/osql/Condition.java index 40bc3c5..a5cb223 100644 --- a/src/main/java/org/teasoft/bee/osql/Condition.java +++ b/src/main/java/org/teasoft/bee/osql/Condition.java @@ -66,7 +66,7 @@ public interface Condition extends ConditionAssistant { /** * 添加一个表达式条件.Add a expression condition. *
此方法不能用于SQL的update set. - * eg: opWithField(field1,Op.eq,field2)-->field1=field2 + * eg: opWithField(field1,Op.gt,field2)-->where field1>field2 * @param field1 first field * @param Op 操作符.operator. * @param field2 second field -- Gitee From 084f0fb2b65be7ebbad12bea7d923adee3318b7f Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sun, 14 Mar 2021 10:37:44 +0800 Subject: [PATCH 013/124] update desc:multi-Datasource function is transparent to the code,just need update the config --- README_CN.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README_CN.md b/README_CN.md index c858e79..43c2dc7 100644 --- a/README_CN.md +++ b/README_CN.md @@ -40,7 +40,7 @@ jdk1.7+ * 13.**多种DB**支持轻松扩展(MySQL,MariaDB,Oracle,H2,SQLite,PostgreSQL等直接可用)。 * 14.**无**第三方插件依赖;可零配置使用。 * 15.提供表对应的Javabean**自动生成工具**,Javaweb**后端代码**根据**模板自动生成**;能打印非占位符的**可执行sql**,方便调试。 -* 16.支持**读写分离**一主多从, 仅**分库**等**多数据源**模式。 +* 16.支持**读写分离**一主多从, 仅**分库**等**多数据源**模式(对以前的代码无需修改,该功能对代码是透明的,即无需额外编码)。 * 17.**分布式**环境下生成**连续单调递增**(在一个workerid内),**全局唯一**数字**id**;提供自然简单的分布式主键生成方式。 * 18.**支持同库分表,动态表名映射**。 * 19.**性能好:接近JDBC的速度;文件小:Bee V1.8 jar 仅217k**。 @@ -59,7 +59,7 @@ SuidRich调整selectById方法且String类型参数的id智能识别Javabean的i 加强聚合函数cont,sum,avg,min,max功能,Condition增加方法: public Condition selectFun(FunctionType functionType,String fieldForFun); public Condition selectFun(FunctionType functionType,String fieldForFun,String alias); -Condition 添加方法:opWithField,setWithField 支持像:field1=field2的表达式 +Condition 添加方法:opWithField,setWithField 支持像:field1=field2的表达式 无Javabean,用map承载需要转换的实体信息,操作数据库(查询,删除数据). 支持读取Excel(*.xls,*.xlsx),并将数据转成List,且导入到数据库(bee-ext). 多表关联查询支持多个关联条件. -- Gitee From 4437b69ec92932d49c450ec0e77fccccfc708b5a Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sun, 14 Mar 2021 11:05:11 +0800 Subject: [PATCH 014/124] update the comment --- src/main/java/org/teasoft/bee/osql/Suid.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/teasoft/bee/osql/Suid.java b/src/main/java/org/teasoft/bee/osql/Suid.java index 706f9b4..50241e5 100644 --- a/src/main/java/org/teasoft/bee/osql/Suid.java +++ b/src/main/java/org/teasoft/bee/osql/Suid.java @@ -113,12 +113,12 @@ public interface Suid { public Suid setDynamicParameter(String para,String value); /** - * declare begin Same Connection for some ORM operation. + * 声明开始使用同一Connection.declare begin Same Connection for some ORM operation. */ public void beginSameConnection(); /** - * declare end Same Connection for some ORM operation. + * 声明结束使用同一Connection.declare end Same Connection for some ORM operation. */ public void endSameConnection(); -- Gitee From e054f1970465d871d884f171729c3ae083c09dee Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sun, 14 Mar 2021 11:22:14 +0800 Subject: [PATCH 015/124] update comment --- src/main/java/org/teasoft/bee/osql/Suid.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/teasoft/bee/osql/Suid.java b/src/main/java/org/teasoft/bee/osql/Suid.java index 50241e5..1c984bc 100644 --- a/src/main/java/org/teasoft/bee/osql/Suid.java +++ b/src/main/java/org/teasoft/bee/osql/Suid.java @@ -114,11 +114,13 @@ public interface Suid { /** * 声明开始使用同一Connection.declare begin Same Connection for some ORM operation. + * @since 1.9 */ public void beginSameConnection(); /** * 声明结束使用同一Connection.declare end Same Connection for some ORM operation. + * @since 1.9 */ public void endSameConnection(); -- Gitee From f06eae6907852cd5e830d46ecca21913c5e36ee4 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sun, 14 Mar 2021 11:22:14 +0800 Subject: [PATCH 016/124] update comment --- src/main/java/org/teasoft/bee/osql/Suid.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/teasoft/bee/osql/Suid.java b/src/main/java/org/teasoft/bee/osql/Suid.java index 50241e5..1c984bc 100644 --- a/src/main/java/org/teasoft/bee/osql/Suid.java +++ b/src/main/java/org/teasoft/bee/osql/Suid.java @@ -114,11 +114,13 @@ public interface Suid { /** * 声明开始使用同一Connection.declare begin Same Connection for some ORM operation. + * @since 1.9 */ public void beginSameConnection(); /** * 声明结束使用同一Connection.declare end Same Connection for some ORM operation. + * @since 1.9 */ public void endSameConnection(); -- Gitee From e5b3173056b3a293b78424dfa98a1b14fec68d4c Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sun, 14 Mar 2021 12:10:12 +0800 Subject: [PATCH 017/124] update --- src/main/java/org/teasoft/bee/osql/Suid.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/teasoft/bee/osql/Suid.java b/src/main/java/org/teasoft/bee/osql/Suid.java index 1c984bc..802460d 100644 --- a/src/main/java/org/teasoft/bee/osql/Suid.java +++ b/src/main/java/org/teasoft/bee/osql/Suid.java @@ -122,6 +122,6 @@ public interface Suid { * 声明结束使用同一Connection.declare end Same Connection for some ORM operation. * @since 1.9 */ - public void endSameConnection(); + public void endSameConnection(); } -- Gitee From 874208deb40e83607241881b2a3486492bdc0a12 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sun, 14 Mar 2021 12:13:09 +0800 Subject: [PATCH 018/124] update --- src/main/java/org/teasoft/bee/osql/Suid.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/teasoft/bee/osql/Suid.java b/src/main/java/org/teasoft/bee/osql/Suid.java index 802460d..1c984bc 100644 --- a/src/main/java/org/teasoft/bee/osql/Suid.java +++ b/src/main/java/org/teasoft/bee/osql/Suid.java @@ -122,6 +122,6 @@ public interface Suid { * 声明结束使用同一Connection.declare end Same Connection for some ORM operation. * @since 1.9 */ - public void endSameConnection(); + public void endSameConnection(); } -- Gitee From 314ca19217b40488e6f87b6a3a91b2f6d4932ff1 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sun, 14 Mar 2021 23:45:27 +0800 Subject: [PATCH 019/124] update for V1.9 API --- .../org/teasoft/bee/osql/IncludeType.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/teasoft/bee/osql/IncludeType.java b/src/main/java/org/teasoft/bee/osql/IncludeType.java index 7e0a7d4..f068d5c 100644 --- a/src/main/java/org/teasoft/bee/osql/IncludeType.java +++ b/src/main/java/org/teasoft/bee/osql/IncludeType.java @@ -8,11 +8,28 @@ package org.teasoft.bee.osql; public enum IncludeType { // -1 for both exclude 留用 + /** + * exclude: NULL and "" + */ EXCLUDE_BOTH(-1), //v1.9 + + /** + * include: NULL + */ INCLUDE_NULL(0), - INCLUDE_EMPTY(1), // "" - INCLUDE_BOTH(2), // NULL and "" - EXCLUDE_THREE(-3); //exclude: NULL and "" and " " + /** + * include: "" + */ + INCLUDE_EMPTY(1), + + /** + * include: NULL and "" + */ + INCLUDE_BOTH(2), + /** + * exclude: NULL , "" and " " + */ + EXCLUDE_THREE(-3); private final int value; -- Gitee From e367bd5cfa197d1187638c80305f279f7b8473f4 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sun, 14 Mar 2021 23:48:15 +0800 Subject: [PATCH 020/124] update for V1.9 API --- src/main/java/org/teasoft/bee/osql/MapSqlSetting.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/teasoft/bee/osql/MapSqlSetting.java b/src/main/java/org/teasoft/bee/osql/MapSqlSetting.java index e56ef23..152959f 100644 --- a/src/main/java/org/teasoft/bee/osql/MapSqlSetting.java +++ b/src/main/java/org/teasoft/bee/osql/MapSqlSetting.java @@ -25,7 +25,7 @@ package org.teasoft.bee.osql; public enum MapSqlSetting { /** - * 是否命令转换.Is naming transfer. value is 'true' or 'false',default is 'false' + * 是否命名转换.Is naming transfer. value is 'true' or 'false',default is 'false' * 真时,会根据配置的规则(bee.properties)如进行转换;假时不转换. * if true, will transfer by the rule (eg: bee.properties). if false,do not transfer. */ -- Gitee From 658ce085d4710c77b62143fec8f050234538a98c Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sun, 14 Mar 2021 23:51:03 +0800 Subject: [PATCH 021/124] update for V1.9 API --- src/main/java/org/teasoft/bee/osql/MapSuid.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/teasoft/bee/osql/MapSuid.java b/src/main/java/org/teasoft/bee/osql/MapSuid.java index 3e2f39c..ba0b975 100644 --- a/src/main/java/org/teasoft/bee/osql/MapSuid.java +++ b/src/main/java/org/teasoft/bee/osql/MapSuid.java @@ -21,7 +21,7 @@ import java.util.List; import java.util.Map; /** - * 使用Map而非具体实体的数据库操作接口,默认不处理null和空字符串(因要与Suid,SuidRich风格兼容). + * 使用Map而非具体实体的数据库操作接口,默认不处理null和空字符串(因要与Suid,SuidRich风格兼容) *
Database operation interface using map instead of specific entity, *
the null and empty string are not handled by default. * Suid (select,update,insert,delete) -- Gitee From 3976c673841735c6dd761c7e8000668c31f0ba18 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sun, 14 Mar 2021 23:51:36 +0800 Subject: [PATCH 022/124] update for V1.9 API --- src/main/java/org/teasoft/bee/osql/OrderType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/teasoft/bee/osql/OrderType.java b/src/main/java/org/teasoft/bee/osql/OrderType.java index 7b83462..1a1b384 100644 --- a/src/main/java/org/teasoft/bee/osql/OrderType.java +++ b/src/main/java/org/teasoft/bee/osql/OrderType.java @@ -24,7 +24,7 @@ public enum OrderType { } /** - * 返回排序类型. + * 返回排序类型.return type of order. * @return type of order. */ public String getName(){ -- Gitee From a27336678d5f9e6ea75a48ff4c122a0bfc4e5278 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sun, 14 Mar 2021 23:51:42 +0800 Subject: [PATCH 023/124] update for V1.9 API --- src/main/java/org/teasoft/bee/osql/Suid.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/teasoft/bee/osql/Suid.java b/src/main/java/org/teasoft/bee/osql/Suid.java index 1c984bc..d52ad9f 100644 --- a/src/main/java/org/teasoft/bee/osql/Suid.java +++ b/src/main/java/org/teasoft/bee/osql/Suid.java @@ -104,7 +104,7 @@ public interface Suid { public int delete(T entity,Condition condition); /** - * 为动态表名、实体名参数设置值.for dynamic table & entity name + * 为动态表名、实体名参数设置值.set dynamic parameter for dynamic table & entity name * @param para parameter name * @param value parameter value * @return Suid -- Gitee From e006fbe5cc9d7f10dd7f724d8377d8b525a1e890 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sun, 14 Mar 2021 23:51:47 +0800 Subject: [PATCH 024/124] update for V1.9 API --- src/main/java/org/teasoft/bee/osql/SuidRich.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/teasoft/bee/osql/SuidRich.java b/src/main/java/org/teasoft/bee/osql/SuidRich.java index 42a8cf2..512bd64 100644 --- a/src/main/java/org/teasoft/bee/osql/SuidRich.java +++ b/src/main/java/org/teasoft/bee/osql/SuidRich.java @@ -135,8 +135,8 @@ public interface SuidRich extends Suid { public String selectWithFun(T entity, FunctionType functionType, String fieldForFun); /** - * 使用函数查询一个统计结果,通过Condition可添加复杂过滤条件.只查询一个统计结果. - * Select result with one function,Just select one function. + * 使用函数查询一个统计结果,通过Condition可添加复杂过滤条件(一次只查询一个统计结果) + * Select result with one function,just select one function at a time. * @param entity 传入的实体对象,且不能为空 * @param functionType MAX,MIN,SUM,AVG,COUNT * @param fieldForFun 需要使用函数的字段 @@ -391,7 +391,7 @@ public interface SuidRich extends Suid { /** * 根据实体对象entity查询数据.Select record according to entity. - * @deprecated {@link Suid#select(Object,Condition)}方法中,可以通过condition设置includeType. + * @deprecated {@link Suid#select(Object,Condition)}方法中,可以通过condition设置includeType.can set includeType via condition. * @param entity 与表对应的实体对象,且不能为空 * id为null时不作为过滤条件 * @param includeType 空字符串与null是否包含设置 @@ -407,7 +407,7 @@ public interface SuidRich extends Suid { /** * 根据实体对象entity查询数据,并以Json格式返回 *
Select and return data in Json format according to entity object. - * @deprecated {@link SuidRich#selectJson(Object,Condition)}方法中,可以通过condition设置includeType. + * @deprecated {@link SuidRich#selectJson(Object,Condition)}方法中,可以通过condition设置includeType.can set includeType via condition. * @param entity 与表对应的实体对象,且不能为空 * id为null不作为过滤条件 * @param includeType 空字符串与null是否包含设置 @@ -474,8 +474,7 @@ public interface SuidRich extends Suid { public int updateBy(T entity,String whereFields,Condition condition); /** - * 此方法,相当于SuidRich接口的 updateBy(entity,"id",condition); - * 更新记录,且可以指定作为条件的字段.Update record according to whereFields. + * 此方法,相当于调用SuidRich接口的 updateBy(entity,"id",condition); it is equivalent to updateBy(entity,"id",condition) * @param entity 实体类对象,不能为空 * entity中除了id字段,作为set部分(默认只处理非空,非null的字段) * @param condition 用来设置默认情况不能表达的条件. @@ -504,7 +503,8 @@ public interface SuidRich extends Suid { /** - * 当SQL update的set表达式通过Condition定义时,可以不用再指定set使用的字段. + * 更新记录,高级条件可通过Condition参数设置 Update record,and can help with Condition. + *
当SQL update的set表达式通过Condition定义时,可以不用再指定set使用的字段. * @param entity 实体类对象,不能为空 * entity默认有值的字段会转成field=value的形式,其它形式可通过condition指定.condition中op,between等方法设置的转换到where中的字段,默认情况不会再处理.
* If the field of entity is not null or empty, it will be translate to field=value.Other can define with condition.
-- Gitee From ede0a312ea4f7c40fec6211f8486c1dc54858720 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Mon, 15 Mar 2021 11:04:11 +0800 Subject: [PATCH 025/124] update for V1.9 API --- .../java/org/teasoft/bee/osql/SuidRich.java | 77 +++++++++++-------- 1 file changed, 46 insertions(+), 31 deletions(-) diff --git a/src/main/java/org/teasoft/bee/osql/SuidRich.java b/src/main/java/org/teasoft/bee/osql/SuidRich.java index 512bd64..e3364f3 100644 --- a/src/main/java/org/teasoft/bee/osql/SuidRich.java +++ b/src/main/java/org/teasoft/bee/osql/SuidRich.java @@ -24,6 +24,19 @@ import java.util.List; * 该接口比Suid接口提供更多的参数选择 *
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显示设置). + * + *
updateBy方法中,String whereFields(若有),可以指明用于SQL中WHERE的字段.当指定了whereFields, 没在whereFields的字段,将默认 + *
转换为SQL UPDATE语句的SET部分(默认过滤NULL和空字符串,可通过IncludeType显示设置);另外,需要注意的是,id字段是不允许更改的. + *
同一个实体的某个属性的值,若用于WHERE部分了,再用于UPDATE SET部分就没有意义(因为此时它们的值是一样的),但可以用Condition的 + *
set(String fieldName, Number num)等方法设置;Condition的方法set,setMultiply,setAdd,setWithField,是在处理WHERE字段前 + *
已完成处理的,所以不受指定的WHERE条件字段的影响. + * * @author Kingstar * Create on 2013-6-30 22:06:18 * @since 1.0 @@ -110,7 +123,7 @@ public interface SuidRich extends Suid { /** * 根据实体对象entity查询数据,并返回Json格式结果 *
Select and return data in Json format according to entity object. - * @param entity 与表对应的实体对象,且不能为空 + * @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. @@ -127,9 +140,9 @@ public interface SuidRich extends Suid { /** * 使用函数查询一个统计结果.Select result with one function,Just select one function. - * @param entity 传入的实体对象,且不能为空 + * @param entity 传入的实体对象,且不能为空.table's entity(do not allow null). * @param functionType MAX,MIN,SUM,AVG,COUNT - * @param fieldForFun 需要使用函数的字段 + * @param fieldForFun 需要使用函数的字段.field for function. * @return 一个函数查询的结果.one function result. */ public String selectWithFun(T entity, FunctionType functionType, String fieldForFun); @@ -137,9 +150,9 @@ public interface SuidRich extends Suid { /** * 使用函数查询一个统计结果,通过Condition可添加复杂过滤条件(一次只查询一个统计结果) * Select result with one function,just select one function at a time. - * @param entity 传入的实体对象,且不能为空 + * @param entity 传入的实体对象,且不能为空.table's entity(do not allow null). * @param functionType MAX,MIN,SUM,AVG,COUNT - * @param fieldForFun 需要使用函数的字段 + * @param fieldForFun 需要使用函数的字段.field for function. * @param condition condition.若condition没有设置IncludeType,默认过滤NULL和空字符串(但condition中op,between,notBetween方法设置的字段,不受includeType的值影响.) *
condition的selectFun方法将被忽略.will ignore the condition's selectFun method. * @return 一个函数查询的结果.one function result. @@ -167,7 +180,7 @@ public interface SuidRich extends Suid { /** * 查询应用排序的结果,排序的字段默认按升序排列 * Select result with order,order type default is:asc - * @param entity 传入的实体对象,且不能为空 + * @param entity 传入的实体对象,且不能为空.table's entity(do not allow null). * @param orderFields 排序字段列表,多个用逗号隔开 * @return 可包含多个有排序的实体(多条记录)的list. list which contains more than one entity. */ @@ -176,7 +189,7 @@ public interface SuidRich extends Suid { /** * 查询应用排序的结果 * Select result with order. - * @param entity 传入的实体对象,且不能为空 + * @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. @@ -185,19 +198,24 @@ public interface SuidRich extends Suid { /** * 更新记录,且可以指定需要更新的字段.Update record, can list update fields. - * @param entity 实体类对象,不能为空 + * @param entity 实体类对象,不能为空.table's entity(do not allow null). * @param updateFields 需要更新的字段列表,多个字段用逗号隔开(列表中有的字段都会更新),该属性不允许为空, *
除了updateFields中声明要更新的字段,其它非空,非null的字段作为过滤条件,转成SQL的where表达式. + *
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 成功更新的记录数.the numbers of update record(s) successfully. */ public int update(T entity,String updateFields); /** * 根据实体对象entity更新数据,可以指定需要更新的字段.Update record according to entity. - * @param entity 与表对应的实体对象,且不能为空 + * @param entity 与表对应的实体对象,且不能为空.table's entity(do not allow null). * id为null不作为过滤条件 * @param updateFields 需要更新的字段列表,多个字段用逗号隔开(列表中有的字段都会更新),该属性不允许为空,且不受includeType参数的影响,默认每个字段会被转化成SQL update的set表达式 - * @param includeType 空字符串与null是否包含设置(是否作为过滤条件) + *
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 includeType 空字符串与null是否作为过滤条件.whether null string and null as a filter conditions. * @return 成功更新的记录数.the numbers of update record(s) successfully. */ public int update(T entity,String updateFields,IncludeType includeType); @@ -290,8 +308,8 @@ public interface SuidRich extends Suid { /** * 根据实体对象entity中id更新该实体对象的数据.Update record according to entity. - * @param entity 与表对应的实体对象,且不能为空;entity中id字段不能为空,作为过虑条件 - * id为null将引发ObjSQLException. + * @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 成功更新的记录数.the numbers of update record(s) successfully. */ @@ -299,7 +317,7 @@ public interface SuidRich extends Suid { /** * 根据实体对象entity插入数据.Insert record according to entity. - * @param entity 与表对应的实体对象,且不能为空 + * @param entity 与表对应的实体对象,且不能为空.table's entity(do not allow null). * @param includeType 空字符串与null是否包含设置 * @return 成功插入的记录行数. the number of inserted record(s) successfully. */ @@ -307,8 +325,8 @@ public interface SuidRich extends Suid { /** * 根据实体对象entity删除数据.Delete record according to entity. - * @param entity 与表对应的实体对象,且不能为空 - * id为null不作为过滤条件 + * @param entity 与表对应的实体对象,且不能为空,id为null不作为过滤条件.table's entity(do not allow null). + * * @param includeType 空字符串与null是否包含设置 * @return 成功删除的记录行数. the number of deleted record(s) successfully. */ @@ -317,8 +335,7 @@ public interface SuidRich extends Suid { /** * 根据实体对象entity查询并返回Json格式的数据 *
Select and return data in Json format according to entity object. - * @param entity 与表对应的实体对象,且不能为空 - * id为null不作为过滤条件 + * @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. * @since 1.1 @@ -392,8 +409,7 @@ public interface SuidRich extends Suid { /** * 根据实体对象entity查询数据.Select record according to entity. * @deprecated {@link Suid#select(Object,Condition)}方法中,可以通过condition设置includeType.can set includeType via condition. - * @param entity 与表对应的实体对象,且不能为空 - * id为null时不作为过滤条件 + * @param entity 与表对应的实体对象,且不能为空,id为null不作为过滤条件.table's entity(do not allow null). * @param includeType 空字符串与null是否包含设置 * @param condition entity默认有值的字段会转成field=value的形式,其它形式可通过condition指定.condition使用过的字段,默认情况不会再处理.
* If the field of entity is not null or empty, it will be translate to field=value.Other can define with condition.
@@ -408,8 +424,7 @@ public interface SuidRich extends Suid { * 根据实体对象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不作为过滤条件 + * @param entity 与表对应的实体对象,且不能为空,id为null不作为过滤条件.table's entity(do not allow null). * @param includeType 空字符串与null是否包含设置 * @param condition entity默认有值的字段会转成field=value的形式,其它形式可通过condition指定.condition使用过的字段,默认情况不会再处理.
* If the field of entity is not null or empty, it will be translate to field=value.Other can define with condition.
@@ -424,8 +439,7 @@ public interface SuidRich extends Suid { /** * 根据实体对象entity查询数据,并以Json格式返回 *
Select and return data in Json format according to entity object. - * @param entity 与表对应的实体对象,且不能为空 - * id为null不作为过滤条件 + * @param entity 与表对应的实体对象,且不能为空, id为null不作为过滤条件.table's entity(do not allow null). * @param condition entity默认有值的字段会转成field=value的形式,其它形式可通过condition指定.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的值影响.) @@ -437,7 +451,7 @@ public interface SuidRich extends Suid { /** * 更新记录,且可以指定作为条件的字段.Update record according to whereFields. - * @param entity 实体类对象,不能为空 + * @param entity 实体类对象,不能为空.table's entity(do not allow null). * 没指定为whereFields的字段,作为set部分,默认只处理非空,非null的字段 * @param whereFields 作为SQL中where条件的字段列表,多个字段用逗号隔开(列表中有的字段都会作为条件); * 指定作为条件的,都转换.id为null不作为过滤条件 @@ -452,7 +466,7 @@ public interface SuidRich extends Suid { * 没指定为whereFields的字段,作为set部分. * @param whereFields 作为SQL中where条件的字段列表,多个字段用逗号隔开(列表中有的字段都会作为条件); * 指定作为条件的,都转换.id为null不作为过滤条件 - * @param includeType 空字符串与null是否包含设置(是否作为过滤条件) + * @param includeType 空字符串与null是否作为过滤条件.whether null string and null as a filter conditions. * @return 成功更新的记录数.the numbers of update record(s) successfully. * @since 1.6 */ @@ -460,7 +474,7 @@ public interface SuidRich extends Suid { /** * 更新记录,且可以指定作为条件的字段.Update record according to whereFields. - * @param entity 实体类对象,不能为空 + * @param entity 实体类对象,不能为空.table's entity(do not allow null). * 没指定为whereFields的字段,作为set部分(默认只处理非空,非null的字段) * @param whereFields 作为SQL中where条件的字段列表,多个字段用逗号隔开(列表中有的字段都会作为条件); * 指定作为条件的,都转换.id为null不作为过滤条件. @@ -475,7 +489,7 @@ public interface SuidRich extends Suid { /** * 此方法,相当于调用SuidRich接口的 updateBy(entity,"id",condition); it is equivalent to updateBy(entity,"id",condition) - * @param entity 实体类对象,不能为空 + * @param entity 实体类对象,不能为空.table's entity(do not allow null). * entity中除了id字段,作为set部分(默认只处理非空,非null的字段) * @param condition 用来设置默认情况不能表达的条件. * 若condition没有设置IncludeType,默认过滤NULL和空字符串(但condition中op,between,notBetween方法设置的字段,不受includeType的值影响.) @@ -485,15 +499,17 @@ public interface SuidRich extends Suid { */ public int updateById(T entity,Condition condition); - /** * 更新记录,且可以指定需要更新的字段,高级条件可通过Condition参数设置.Update record, can list update fields. - * @param entity 实体类对象,不能为空 + * @param entity 实体类对象,不能为空.table's entity(do not allow null). * entity默认有值的字段会转成field=value的形式,其它形式可通过condition指定.condition中op,between等方法设置的转换到where中的字段,默认情况不会再处理.
* 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. + *
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的值影响.) * @return 成功更新的记录数.the numbers of update record(s) successfully. @@ -501,11 +517,10 @@ public interface SuidRich extends Suid { */ public int update(T entity,String updateFields,Condition condition); - /** * 更新记录,高级条件可通过Condition参数设置 Update record,and can help with Condition. *
当SQL update的set表达式通过Condition定义时,可以不用再指定set使用的字段. - * @param entity 实体类对象,不能为空 + * @param entity 实体类对象,不能为空.table's entity(do not allow null). * entity默认有值的字段会转成field=value的形式,其它形式可通过condition指定.condition中op,between等方法设置的转换到where中的字段,默认情况不会再处理.
* If the field of entity is not null or empty, it will be translate to field=value.Other can define with condition.
* @param condition -- Gitee From 7b518d836db0943c8bb09783005845e3836e85a1 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Mon, 15 Mar 2021 14:00:47 +0800 Subject: [PATCH 026/124] close method: Condition having(String expressionStr) --- src/main/java/org/teasoft/bee/osql/Condition.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/teasoft/bee/osql/Condition.java b/src/main/java/org/teasoft/bee/osql/Condition.java index a5cb223..d5fe4b9 100644 --- a/src/main/java/org/teasoft/bee/osql/Condition.java +++ b/src/main/java/org/teasoft/bee/osql/Condition.java @@ -150,7 +150,10 @@ public interface Condition extends ConditionAssistant { * expression string,if contain field,it will not be translated. * @return Condition */ - public Condition having(String expressionStr); +// public Condition having(String expressionStr); + //closed. because can use: +// .having(FunctionType.COUNT, "*", Op.ge, 1) +// .having(FunctionType.COUNT, "distinct(userid)", Op.ge, 1) /** * eg: having(FunctionType.MIN, "field", Op.ge, 60)-->having min(field)>=60 -- Gitee From e00c390b30deaca7e1e30064990ee85cb219fd4c Mon Sep 17 00:00:00 2001 From: Kingstar Date: Tue, 16 Mar 2021 21:51:35 +0800 Subject: [PATCH 027/124] update V1.9 function list --- Changed_Log_CN.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Changed_Log_CN.md b/Changed_Log_CN.md index e80bf88..f11bf3e 100644 --- a/Changed_Log_CN.md +++ b/Changed_Log_CN.md @@ -187,6 +187,7 @@ SuidRich调整selectById方法且String类型参数的id智能识别Javabean的i 加强聚合函数cont,sum,avg,min,max功能,Condition增加方法: public Condition selectFun(FunctionType functionType,String fieldForFun); public Condition selectFun(FunctionType functionType,String fieldForFun,String alias); +Condition 添加方法:opWithField,setWithField 支持像:field1=field2的表达式 无Javabean,用map承载需要转换的实体信息,操作数据库(查询,删除数据). 支持读取Excel(*.xls,*.xlsx),并将数据转成List,且导入到数据库(bee-ext). 多表关联查询支持多个关联条件. -- Gitee From 12813642cc1258e8d10ae089a9b4b4e3722481c3 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Wed, 17 Mar 2021 16:19:52 +0800 Subject: [PATCH 028/124] update main feature list for V1.9 --- README_CN.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/README_CN.md b/README_CN.md index 43c2dc7..1549a32 100644 --- a/README_CN.md +++ b/README_CN.md @@ -28,22 +28,25 @@ jdk1.7+ * 1.**接口简单,使用方便**。Suid接口中对应SQL语言的select,update,insert,delete操作提供**4个同名方法**。 * 2.使用了Bee,你可以不用再另外编写dao代码,直接调用Bee的api即可完成对DB的操作。 * 3.**约定优于配置**:Javabean没有注解,也不需要xml映射文件,只是纯的Javabean即可,甚至get,set方法不用也可以。 -* 4.**智能化自动过滤**null和空字符串,不用再写判断非空的代码。 +* 4.**智能化自动过滤**null和空字符串,不再需要写判断非空的代码。 * 5.**动态/任意组合**查询条件,不需要提前准备dao接口,有新的查询需求也不用修改或添加接口。 * 6.支持原生SQL排序, **原生语句分页**(不需要将全部数据查出来)。 * 7.支持直接返回**Json**格式查询结果; 链式编程。 -* 8.支持**事务**、**for update**,支持**批处理**操作,支持原生SQL(**自定义sql**语句),支持**存储过程**。 +* 8.支持**事务**、多个ORM操作使用同一连接、**for update**,支持**批处理**操作,支持原生SQL(**自定义sql**语句),支持**存储过程**。 * 9.支持**只查询一部分字段**。 * 10.支持面向对象方式复杂查询、**多表查询**(无n+1问题; 支持:一对一,一对多,多对一,多对多)。 * 11.**一级缓存**,概念简单,功能强大;一级缓存也可以**像JVM一样进行细粒度调优**;**智能缓存**,支持更新配置表,**不用重启**。 * 12.表名与实体名、字段名与属性名映射默认提供多种实现,且支持**自定义映射规则扩展**。 * 13.**多种DB**支持轻松扩展(MySQL,MariaDB,Oracle,H2,SQLite,PostgreSQL等直接可用)。 -* 14.**无**第三方插件依赖;可零配置使用。 -* 15.提供表对应的Javabean**自动生成工具**,Javaweb**后端代码**根据**模板自动生成**;能打印非占位符的**可执行sql**,方便调试。 -* 16.支持**读写分离**一主多从, 仅**分库**等**多数据源**模式(对以前的代码无需修改,该功能对代码是透明的,即无需额外编码)。 -* 17.**分布式**环境下生成**连续单调递增**(在一个workerid内),**全局唯一**数字**id**;提供自然简单的分布式主键生成方式。 -* 18.**支持同库分表,动态表名映射**。 +* 14.支持**读写分离**一主多从, 仅**分库**等**多数据源**模式(对以前的代码无需修改,该功能对代码是透明的,即无需额外编码)。 +* 15.**分布式**环境下生成**连续单调递增**(在一个workerid内),**全局唯一**数字**id**;提供自然简单的分布式主键生成方式。 +* 16.**支持同库分表,动态表名映射**。 +* 17.可以不用表对应的Javabean也能操作DB。 +* 18.**无**第三方插件依赖;可零配置使用。 * 19.**性能好:接近JDBC的速度;文件小:Bee V1.8 jar 仅217k**。 +辅助功能: +* 20.提供表对应的Javabean**自动生成工具**,Javaweb**后端代码**根据**模板自动生成**;能打印非占位符的**可执行sql**,方便调试。 +* 21.支持**读取Excel**,从Excel导入数据到DB,操作简单。 ## 最新功能介绍: -- Gitee From fc2496e95bbea102b8d243e988b1b606bea76afb Mon Sep 17 00:00:00 2001 From: Kingstar Date: Wed, 17 Mar 2021 16:20:29 +0800 Subject: [PATCH 029/124] add method modify(String sql) for PreparedSql --- src/main/java/org/teasoft/bee/osql/PreparedSql.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/org/teasoft/bee/osql/PreparedSql.java b/src/main/java/org/teasoft/bee/osql/PreparedSql.java index ebcfc59..7145c74 100644 --- a/src/main/java/org/teasoft/bee/osql/PreparedSql.java +++ b/src/main/java/org/teasoft/bee/osql/PreparedSql.java @@ -295,4 +295,17 @@ public interface PreparedSql { */ @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. + * @since 1.9 + */ + @Deprecated + public int modify(String sql); } -- Gitee From 375fd9707a49bafdc4ca118f16112c7acafc6bc5 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Wed, 17 Mar 2021 16:21:40 +0800 Subject: [PATCH 030/124] V1.9 change for Select chain coding --- .../org/teasoft/bee/osql/chain/Select.java | 53 +++++++++++-------- 1 file changed, 31 insertions(+), 22 deletions(-) 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 02ce6d0..14190aa 100644 --- a/src/main/java/org/teasoft/bee/osql/chain/Select.java +++ b/src/main/java/org/teasoft/bee/osql/chain/Select.java @@ -26,10 +26,20 @@ import org.teasoft.bee.osql.OrderType; */ public interface Select extends ToSql{ + //<==============condition + + /** + * 添加左括号.add "(" + * @return Update + */ public Select lParentheses(); + + /** + * 添加右括号.add ")" + * @return Update + */ public Select rParentheses(); - //<==============condition public Select op(String field, Op Op, String value); public Select op(String field, Op Op, Number value); @@ -50,6 +60,19 @@ public interface Select extends ToSql{ public Select where(); public Select where(String expression) ; + + public Select between(String field, Number low, Number high); + public Select notBetween(String field, Number low, Number high); + + public Select isNull(String field); + public Select isNotNull(String field); + + public Select in(String field, Number... valueList); + public Select notIn(String field, Number... valueList); + + public Select in(String field, String valueList); + public Select notIn(String field, String valueList); + //=============> public Select select() ; @@ -62,28 +85,16 @@ public interface Select extends ToSql{ public Select join(String anotherTable) ; - public Select innerjoin(String anotherTable); + public Select innerJoin(String anotherTable); - public Select leftjoin(String anotherTable); + public Select leftJoin(String anotherTable); - public Select rightjoin(String anotherTable); + public Select rightJoin(String anotherTable); public Select on(); public Select on(String expression); - public Select between(String field, Number low, Number high); - public Select notBetween(String field, Number low, Number high); - - public Select isNull(String field); - public Select isNotNull(String field); - - public Select in(String field, Number... valueList); - public Select notIn(String field, Number... valueList); - - public Select in(String field, String valueList); - public Select notIn(String field, String valueList); - public Select groupBy(String field); public Select having(String expression); @@ -97,12 +108,10 @@ public interface Select extends ToSql{ public Select size(int size) ; public Select exists(Select subSelect) ; - public Select exists(String subSelect); +// public Select exists(String subSelect); public Select notExists(Select subSelect); - public Select notExists(String subSelect); +// public Select notExists(String subSelect); - public Select in(Select subSelect); - public Select in(String subSelect) ; - public Select notIn(Select subSelect); - public Select notIn(String subSelect); + public Select in(String field, Select subSelect); + public Select notIn(String field, Select subSelect); } -- Gitee From 97e0053c415dea260a09b54926a139f069a81a35 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Wed, 17 Mar 2021 16:21:51 +0800 Subject: [PATCH 031/124] V1.9 change for Update chain coding --- .../org/teasoft/bee/osql/chain/Update.java | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) 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 42615d1..b8144ba 100644 --- a/src/main/java/org/teasoft/bee/osql/chain/Update.java +++ b/src/main/java/org/teasoft/bee/osql/chain/Update.java @@ -30,9 +30,22 @@ public interface Update extends ToSql{ public Update set(String field, Number value); //<==============condition - public Update op(String field, Op opType, String value); + + /** + * 添加左括号.add "(" + * @return Update + */ + public Update lParentheses(); + + /** + * 添加右括号.add ")" + * @return Update + */ + public Update rParentheses(); + + public Update op(String field, Op Op, String value); - public Update op(String field, Op opType, Number value); + public Update op(String field, Op Op, Number value); public Update op(String field, String value); @@ -40,7 +53,7 @@ public interface Update extends ToSql{ /** * 默认自动加and. Default will automatically add and. - * @return Update + * @return Select */ public Update and(); @@ -50,5 +63,18 @@ public interface Update extends ToSql{ public Update where(); public Update where(String expression) ; + + public Update between(String field, Number low, Number high); + public Update notBetween(String field, Number low, Number high); + + public Update isNull(String field); + public Update isNotNull(String field); + + public Update in(String field, Number... valueList); + public Update notIn(String field, Number... valueList); + + public Update in(String field, String valueList); + public Update notIn(String field, String valueList); + //=============> } -- Gitee From 34219fe21bcecd1a93a3f0d7eb7880233dff124b Mon Sep 17 00:00:00 2001 From: Kingstar Date: Wed, 17 Mar 2021 16:24:18 +0800 Subject: [PATCH 032/124] V1.9 enhance chain coding:Select,Update. --- README_CN.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README_CN.md b/README_CN.md index 1549a32..f0f5e1f 100644 --- a/README_CN.md +++ b/README_CN.md @@ -72,6 +72,7 @@ Condition 添加方法:opWithField,setWithField 支持像:field1=field2的表达 用模板生成文件支持自定义起止标签. 完善DB连接管理. 加强代码质量. +增强链式编程:Select,Update. 更新bee.properties文件中batchSize(bee.osql.insert.batchSize). 修复多表分页查询时,同名字段在部分数据库会混淆的缺陷(oracle). 修改缺陷:update默认主键为id时,无id字段或id为null时,异常处理. -- Gitee From 3fc009586e69e042243a673d33fa9b0ac96a7f8f Mon Sep 17 00:00:00 2001 From: Kingstar Date: Wed, 17 Mar 2021 16:24:27 +0800 Subject: [PATCH 033/124] V1.9 enhance chain coding:Select,Update. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 84ede9d..b3d3513 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,7 @@ 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. +enhance chain coding:Select,Update. update batchSize(bee.osql.insert.batchSize) in bee.properties. 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. -- Gitee From 276d80628e2c543773cc3893ba1d60f38534b8cb Mon Sep 17 00:00:00 2001 From: Kingstar Date: Wed, 17 Mar 2021 23:17:48 +0800 Subject: [PATCH 034/124] add lower SQL Key for chain coding --- .../java/org/teasoft/bee/osql/LowerKey.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/main/java/org/teasoft/bee/osql/LowerKey.java b/src/main/java/org/teasoft/bee/osql/LowerKey.java index ebe576d..f5ab0e5 100644 --- a/src/main/java/org/teasoft/bee/osql/LowerKey.java +++ b/src/main/java/org/teasoft/bee/osql/LowerKey.java @@ -54,6 +54,16 @@ public class LowerKey implements SqlKeyWord { 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() { @@ -195,4 +205,49 @@ public class LowerKey implements SqlKeyWord { return notBetween; } + @Override + public String distinct() { + return distinct; + } + + @Override + public String join() { + return join; + } + + @Override + public String innerJoin() { + return innerJoin; + } + + @Override + public String leftJoin() { + return leftJoin; + } + + @Override + public String rightJoin() { + return rightJoin; + } + + @Override + public String in() { + return in; + } + + @Override + public String notIn() { + return notIn; + } + + @Override + public String exists() { + return exists; + } + + @Override + public String notExists() { + return notExists; + } + } -- Gitee From 082474da721d3d256ba19fc1aa6b956cb8f16e3e Mon Sep 17 00:00:00 2001 From: Kingstar Date: Wed, 17 Mar 2021 23:18:00 +0800 Subject: [PATCH 035/124] add lower SQL Key for chain coding --- .../java/org/teasoft/bee/osql/UpperKey.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/main/java/org/teasoft/bee/osql/UpperKey.java b/src/main/java/org/teasoft/bee/osql/UpperKey.java index ac7fcc2..a5f4547 100644 --- a/src/main/java/org/teasoft/bee/osql/UpperKey.java +++ b/src/main/java/org/teasoft/bee/osql/UpperKey.java @@ -56,6 +56,16 @@ public class UpperKey implements SqlKeyWord { 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; @@ -196,4 +206,49 @@ public class UpperKey implements SqlKeyWord { return notBetween; } + @Override + public String distinct() { + return distinct; + } + + @Override + public String join() { + return join; + } + + @Override + public String innerJoin() { + return innerJoin; + } + + @Override + public String leftJoin() { + return leftJoin; + } + + @Override + public String rightJoin() { + return rightJoin; + } + + @Override + public String in() { + return in; + } + + @Override + public String notIn() { + return notIn; + } + + @Override + public String exists() { + return exists; + } + + @Override + public String notExists() { + return notExists; + } + } -- Gitee From 44ee5721fce205c147bb102c7057926998b66f4e Mon Sep 17 00:00:00 2001 From: Kingstar Date: Wed, 17 Mar 2021 23:18:13 +0800 Subject: [PATCH 036/124] add SQL Key for chain coding --- src/main/java/org/teasoft/bee/osql/SqlKeyWord.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/org/teasoft/bee/osql/SqlKeyWord.java b/src/main/java/org/teasoft/bee/osql/SqlKeyWord.java index cede333..aeb86e5 100644 --- a/src/main/java/org/teasoft/bee/osql/SqlKeyWord.java +++ b/src/main/java/org/teasoft/bee/osql/SqlKeyWord.java @@ -59,4 +59,13 @@ public interface SqlKeyWord { String space(); + String distinct(); + String join(); + String innerJoin(); + String leftJoin(); + String rightJoin(); + String in(); + String notIn(); + String exists(); + String notExists(); } -- Gitee From ce9ae4acdd9cd31af5237bc375da7d578576efbd Mon Sep 17 00:00:00 2001 From: Kingstar Date: Wed, 17 Mar 2021 23:18:44 +0800 Subject: [PATCH 037/124] closed some exception --- .../exception/BeeIllegalAccessException.java | 57 ++++++++++--------- .../exception/BeeInstantiationException.java | 55 +++++++++--------- 2 files changed, 57 insertions(+), 55 deletions(-) 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 75a9cf4..9538e52 100644 --- a/src/main/java/org/teasoft/bee/osql/exception/BeeIllegalAccessException.java +++ b/src/main/java/org/teasoft/bee/osql/exception/BeeIllegalAccessException.java @@ -13,36 +13,37 @@ * 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.exception; import org.teasoft.bee.osql.BeeException; -/** - * 与java.lang.IllegalAccessException对应的异常.Define for java.lang.IllegalAccessException. - * @author Kingstar - * @since 1.4 - */ -public class BeeIllegalAccessException extends BeeException { - - static final long serialVersionUID = -875516993124222230L; - - - public BeeIllegalAccessException() { - super(); - } - - public BeeIllegalAccessException(String message) { - super(message); - } - - public BeeIllegalAccessException(String message, Throwable cause) { - super(message, cause); - } - - public BeeIllegalAccessException(Throwable cause) { - super(cause); - } - -} +*//** + * 与java.lang.IllegalAccessException对应的异常.Define for java.lang.IllegalAccessException. + * @author Kingstar + * @since 1.4 + *//* + public class BeeIllegalAccessException extends BeeException { + + static final long serialVersionUID = -875516993124222230L; + + + public BeeIllegalAccessException() { + super(); + } + + public BeeIllegalAccessException(String message) { + super(message); + } + + public BeeIllegalAccessException(String message, Throwable cause) { + super(message, cause); + } + + public BeeIllegalAccessException(Throwable cause) { + super(cause); + } + + } + */ \ No newline at end of file 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 fa8a4c1..5e462eb 100644 --- a/src/main/java/org/teasoft/bee/osql/exception/BeeInstantiationException.java +++ b/src/main/java/org/teasoft/bee/osql/exception/BeeInstantiationException.java @@ -13,35 +13,36 @@ * 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.exception; import org.teasoft.bee.osql.BeeException; -/** - * 与java.lang.InstantiationException对应的异常. Define for java.lang.InstantiationException. - * @author Kingstar - * @since 1.4 - */ -public class BeeInstantiationException extends BeeException { - - static final long serialVersionUID = -875516993124222231L; - - - public BeeInstantiationException() { - super(); - } - - public BeeInstantiationException(String message) { - super(message); - } - - public BeeInstantiationException(String message, Throwable cause) { - super(message, cause); - } - - public BeeInstantiationException(Throwable cause) { - super(cause); - } -} +*//** + * 与java.lang.InstantiationException对应的异常. Define for java.lang.InstantiationException. + * @author Kingstar + * @since 1.4 + *//* + public class BeeInstantiationException extends BeeException { + + static final long serialVersionUID = -875516993124222231L; + + + public BeeInstantiationException() { + super(); + } + + public BeeInstantiationException(String message) { + super(message); + } + + public BeeInstantiationException(String message, Throwable cause) { + super(message, cause); + } + + public BeeInstantiationException(Throwable cause) { + super(cause); + } + } + */ \ No newline at end of file -- Gitee From e223ba6703c8e8590c50c521b9d4acc009383a00 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 18 Mar 2021 21:24:04 +0800 Subject: [PATCH 038/124] update --- .../exception/BeeIllegalAccessException.java | 56 +++++++++---------- .../exception/BeeInstantiationException.java | 54 +++++++++--------- 2 files changed, 53 insertions(+), 57 deletions(-) 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 9538e52..4b7df00 100644 --- a/src/main/java/org/teasoft/bee/osql/exception/BeeIllegalAccessException.java +++ b/src/main/java/org/teasoft/bee/osql/exception/BeeIllegalAccessException.java @@ -13,37 +13,35 @@ * 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.exception; import org.teasoft.bee.osql.BeeException; -*//** - * 与java.lang.IllegalAccessException对应的异常.Define for java.lang.IllegalAccessException. - * @author Kingstar - * @since 1.4 - *//* - public class BeeIllegalAccessException extends BeeException { - - static final long serialVersionUID = -875516993124222230L; - - - public BeeIllegalAccessException() { - super(); - } - - public BeeIllegalAccessException(String message) { - super(message); - } - - public BeeIllegalAccessException(String message, Throwable cause) { - super(message, cause); - } - - public BeeIllegalAccessException(Throwable cause) { - super(cause); - } - - } - */ \ No newline at end of file +/** + * 与java.lang.IllegalAccessException对应的异常.Define for java.lang.IllegalAccessException. + * @author Kingstar + * @since 1.4 + */ +public class BeeIllegalAccessException extends BeeException { + + static final long serialVersionUID = -875516993124222230L; + + public BeeIllegalAccessException() { + super(); + } + + public BeeIllegalAccessException(String message) { + super(message); + } + + public BeeIllegalAccessException(String message, Throwable cause) { + super(message, cause); + } + + public BeeIllegalAccessException(Throwable cause) { + super(cause); + } + +} 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 5e462eb..ba292a4 100644 --- a/src/main/java/org/teasoft/bee/osql/exception/BeeInstantiationException.java +++ b/src/main/java/org/teasoft/bee/osql/exception/BeeInstantiationException.java @@ -13,36 +13,34 @@ * 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.exception; import org.teasoft.bee.osql.BeeException; -*//** - * 与java.lang.InstantiationException对应的异常. Define for java.lang.InstantiationException. - * @author Kingstar - * @since 1.4 - *//* - public class BeeInstantiationException extends BeeException { - - static final long serialVersionUID = -875516993124222231L; - - - public BeeInstantiationException() { - super(); - } - - public BeeInstantiationException(String message) { - super(message); - } - - public BeeInstantiationException(String message, Throwable cause) { - super(message, cause); - } - - public BeeInstantiationException(Throwable cause) { - super(cause); - } - } - */ \ No newline at end of file +/** + * 与java.lang.InstantiationException对应的异常. Define for java.lang.InstantiationException. + * @author Kingstar + * @since 1.4 + */ +public class BeeInstantiationException extends BeeException { + + static final long serialVersionUID = -875516993124222231L; + + public BeeInstantiationException() { + super(); + } + + public BeeInstantiationException(String message) { + super(message); + } + + public BeeInstantiationException(String message, Throwable cause) { + super(message, cause); + } + + public BeeInstantiationException(Throwable cause) { + super(cause); + } +} -- Gitee From f32fc3745f446aae47c9dc100778b3a816a5dc0b Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 18 Mar 2021 21:24:16 +0800 Subject: [PATCH 039/124] update test --- src/test/java/org/teasoft/bee/BeeExam.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/teasoft/bee/BeeExam.java b/src/test/java/org/teasoft/bee/BeeExam.java index adf2895..91dda1c 100644 --- a/src/test/java/org/teasoft/bee/BeeExam.java +++ b/src/test/java/org/teasoft/bee/BeeExam.java @@ -16,12 +16,17 @@ */ package org.teasoft.bee; +import org.junit.Assert; +import org.junit.Test; + /** * @author Kingstar * @since 1.7.2 */ public class BeeExam { - public static void main(String[] args) { + + @Test + public void test(){ // bee-exam last update time:2020-06-13 13:14 (yyyy-MM-dd HH:mm) //add multi-DataSource support(Write/Read, only Split Database) @@ -69,6 +74,8 @@ public class BeeExam { // // 让开发爱上测试,从Bee开始! + boolean isFinished=false; + System.out.println("测试用例请查看工程:bee-exam"); System.out.println("以下任意一个地址:"); System.out.println("https://gitee.com/automvc/bee-exam"); @@ -92,6 +99,9 @@ public class BeeExam { System.out.println("https://gitee.com/automvc/bee-exam"); System.out.println(""); System.out.println("Let developers like test, starting with Bee!"); + + isFinished=true; + Assert.assertEquals(isFinished,true); } } -- Gitee From cde0c1d8bf1e73c84e4548bd68e3fd163ea6fb42 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Fri, 19 Mar 2021 00:11:29 +0800 Subject: [PATCH 040/124] add coverage info. --- src/test/java/org/teasoft/bee/BeeExam.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/test/java/org/teasoft/bee/BeeExam.java b/src/test/java/org/teasoft/bee/BeeExam.java index 91dda1c..85c7c4a 100644 --- a/src/test/java/org/teasoft/bee/BeeExam.java +++ b/src/test/java/org/teasoft/bee/BeeExam.java @@ -66,6 +66,21 @@ public class BeeExam { // bee-exam(v1.9)-normal(MySQL)-2021-03-11 08.47.40.114.txt // bee-exam(v1.9)-cache-2021-03-11 08.52.07.423.txt +// 2021-03-18 (yyyy-MM-dd) +// Instructions Counters +// Element Coverage +// Bee 90.0% +// Honey 63.6% +// +// Method Counters +// Element Coverage +// Bee 88.0% +// Honey 70.3% +// +// Type Counters +// Element Coverage +// Bee 97.0% +// Honey 86.3% // 测试用例请查看工程:bee-exam // 以下任意一个地址: -- Gitee From 4f8f856d4dd94ca67fab932c33fd4e9f32bd757c Mon Sep 17 00:00:00 2001 From: Kingstar Date: Fri, 19 Mar 2021 00:29:18 +0800 Subject: [PATCH 041/124] add coverage info --- src/test/java/org/teasoft/bee/change-log.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/org/teasoft/bee/change-log.txt b/src/test/java/org/teasoft/bee/change-log.txt index a839d73..aa51132 100644 --- a/src/test/java/org/teasoft/bee/change-log.txt +++ b/src/test/java/org/teasoft/bee/change-log.txt @@ -75,3 +75,5 @@ bee-exam(v1.9)-normal(MySQL)-2021-02-07 11.56.33.739.txt bee-exam(v1.9)-normal(MySQL)-2021-02-14 10.11.34.561.txt bee-exam(v1.9)-normal(MySQL)-2021-03-11 08.47.40.114.txt bee-exam(v1.9)-cache-2021-03-11 08.52.07.423.txt + +add coverage info.2021-03-18 (yyyy-MM-dd) -- Gitee From 6ea88215be7a1e1231487f499b888c5c51515512 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sat, 20 Mar 2021 22:35:59 +0800 Subject: [PATCH 042/124] add test for oracle --- src/test/java/org/teasoft/bee/BeeExam.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/teasoft/bee/BeeExam.java b/src/test/java/org/teasoft/bee/BeeExam.java index 85c7c4a..3f3cd71 100644 --- a/src/test/java/org/teasoft/bee/BeeExam.java +++ b/src/test/java/org/teasoft/bee/BeeExam.java @@ -66,11 +66,14 @@ public class BeeExam { // bee-exam(v1.9)-normal(MySQL)-2021-03-11 08.47.40.114.txt // bee-exam(v1.9)-cache-2021-03-11 08.52.07.423.txt -// 2021-03-18 (yyyy-MM-dd) +// bee-exam(v1.9)-normal(Oracle)-2021-03-20 20.01.44.213.txt +// bee-exam(v1.9)-cache(Oracle)-2021-03-20 20.02.02.758.txt + +// 2021-03-20 (yyyy-MM-dd) // Instructions Counters // Element Coverage -// Bee 90.0% -// Honey 63.6% +// Bee 91.6% +// Honey 65.6% // // Method Counters // Element Coverage -- Gitee From 803d74bd88f63a2bad6b9b5d4d8cccdbeef6d5a4 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sat, 20 Mar 2021 22:36:06 +0800 Subject: [PATCH 043/124] add test for oracle --- src/test/java/org/teasoft/bee/change-log.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test/java/org/teasoft/bee/change-log.txt b/src/test/java/org/teasoft/bee/change-log.txt index aa51132..c7ef3de 100644 --- a/src/test/java/org/teasoft/bee/change-log.txt +++ b/src/test/java/org/teasoft/bee/change-log.txt @@ -77,3 +77,7 @@ bee-exam(v1.9)-normal(MySQL)-2021-03-11 08.47.40.114.txt bee-exam(v1.9)-cache-2021-03-11 08.52.07.423.txt add coverage info.2021-03-18 (yyyy-MM-dd) + +bee-exam(v1.9)-normal(Oracle)-2021-03-20 20.01.44.213.txt +bee-exam(v1.9)-cache(Oracle)-2021-03-20 20.02.02.758.txt + -- Gitee From abbbf62bcc054a690df95901ab4301e7ef9fa4ef Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sat, 20 Mar 2021 23:29:06 +0800 Subject: [PATCH 044/124] add test log for mysql --- src/test/java/org/teasoft/bee/BeeExam.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/org/teasoft/bee/BeeExam.java b/src/test/java/org/teasoft/bee/BeeExam.java index 3f3cd71..12f586c 100644 --- a/src/test/java/org/teasoft/bee/BeeExam.java +++ b/src/test/java/org/teasoft/bee/BeeExam.java @@ -68,6 +68,8 @@ public class BeeExam { // bee-exam(v1.9)-normal(Oracle)-2021-03-20 20.01.44.213.txt // bee-exam(v1.9)-cache(Oracle)-2021-03-20 20.02.02.758.txt +// bee-exam(v1.9)-normal(MySQL)-2021-03-20 23.10.06.324.txt +// bee-exam(v1.9)-cache(MySQL)-2021-03-20 23.10.16.346.txt // 2021-03-20 (yyyy-MM-dd) // Instructions Counters -- Gitee From f796a2ed1477ad979e2b22b608efb0d2b5f61519 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sat, 20 Mar 2021 23:29:16 +0800 Subject: [PATCH 045/124] add test log for mysql --- src/test/java/org/teasoft/bee/change-log.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/teasoft/bee/change-log.txt b/src/test/java/org/teasoft/bee/change-log.txt index c7ef3de..ac32021 100644 --- a/src/test/java/org/teasoft/bee/change-log.txt +++ b/src/test/java/org/teasoft/bee/change-log.txt @@ -80,4 +80,5 @@ add coverage info.2021-03-18 (yyyy-MM-dd) bee-exam(v1.9)-normal(Oracle)-2021-03-20 20.01.44.213.txt bee-exam(v1.9)-cache(Oracle)-2021-03-20 20.02.02.758.txt - +bee-exam(v1.9)-normal(MySQL)-2021-03-20 23.10.06.324.txt +bee-exam(v1.9)-cache(MySQL)-2021-03-20 23.10.16.346.txt -- Gitee From a26af6b4e2c4a98820caea4c004d05bc64578add Mon Sep 17 00:00:00 2001 From: Kingstar Date: Mon, 22 Mar 2021 07:40:15 +0800 Subject: [PATCH 046/124] update comment for setDynamicParameter --- src/main/java/org/teasoft/bee/osql/Suid.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/teasoft/bee/osql/Suid.java b/src/main/java/org/teasoft/bee/osql/Suid.java index d52ad9f..33766d8 100644 --- a/src/main/java/org/teasoft/bee/osql/Suid.java +++ b/src/main/java/org/teasoft/bee/osql/Suid.java @@ -105,6 +105,8 @@ public interface Suid { /** * 为动态表名、实体名参数设置值.set dynamic parameter for dynamic table & entity name + *
本方法的调用要早于Suid(select,update,insert,delete)方法. + *
This method is called earlier than the Suid(select, update, insert, delete) method. * @param para parameter name * @param value parameter value * @return Suid -- Gitee From 93b6e591421f1bfa9d7041584e565c1c636ac2d2 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Mon, 22 Mar 2021 13:16:12 +0800 Subject: [PATCH 047/124] support different type muli-Ds at same time. --- .../java/org/teasoft/bee/osql/BeeAbstractFactory.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/teasoft/bee/osql/BeeAbstractFactory.java b/src/main/java/org/teasoft/bee/osql/BeeAbstractFactory.java index e0c8fb2..fd2b3f6 100644 --- a/src/main/java/org/teasoft/bee/osql/BeeAbstractFactory.java +++ b/src/main/java/org/teasoft/bee/osql/BeeAbstractFactory.java @@ -17,6 +17,7 @@ package org.teasoft.bee.osql; +import java.sql.Connection; import java.util.Map; import javax.sql.DataSource; @@ -32,10 +33,10 @@ public abstract class BeeAbstractFactory { private DataSource dataSource; private Transaction transaction; - + //v1.8 - private Map dataSourceMap; - + private Map dataSourceMap; + public DataSource getDataSource() { return dataSource; } @@ -58,6 +59,9 @@ public abstract class BeeAbstractFactory { public void setDataSourceMap(Map dataSourceMap) { this.dataSourceMap = dataSourceMap; + parseDbNameByDsMap(); } + + protected abstract void parseDbNameByDsMap(); } -- Gitee From c21d51cd8e2e20a8d7808fe632b731c09e33da0a Mon Sep 17 00:00:00 2001 From: Kingstar Date: Mon, 22 Mar 2021 13:16:18 +0800 Subject: [PATCH 048/124] support different type muli-Ds at same time. --- README_CN.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README_CN.md b/README_CN.md index f0f5e1f..532633f 100644 --- a/README_CN.md +++ b/README_CN.md @@ -38,7 +38,7 @@ jdk1.7+ * 11.**一级缓存**,概念简单,功能强大;一级缓存也可以**像JVM一样进行细粒度调优**;**智能缓存**,支持更新配置表,**不用重启**。 * 12.表名与实体名、字段名与属性名映射默认提供多种实现,且支持**自定义映射规则扩展**。 * 13.**多种DB**支持轻松扩展(MySQL,MariaDB,Oracle,H2,SQLite,PostgreSQL等直接可用)。 -* 14.支持**读写分离**一主多从, 仅**分库**等**多数据源**模式(对以前的代码无需修改,该功能对代码是透明的,即无需额外编码)。 +* 14.支持**读写分离**一主多从, 仅**分库**等**多数据源**模式(对以前的代码无需修改,该功能对代码是透明的,即无需额外编码),仅分库**可同时使用多种类型数据库**。 * 15.**分布式**环境下生成**连续单调递增**(在一个workerid内),**全局唯一**数字**id**;提供自然简单的分布式主键生成方式。 * 16.**支持同库分表,动态表名映射**。 * 17.可以不用表对应的Javabean也能操作DB。 @@ -67,6 +67,7 @@ Condition 添加方法:opWithField,setWithField 支持像:field1=field2的表达 支持读取Excel(*.xls,*.xlsx),并将数据转成List,且导入到数据库(bee-ext). 多表关联查询支持多个关联条件. 多个ORM操作使用同一个Connection. +支持同时使用多种类型数据库的数据源. 支持长度大于0空字符串忽略处理,如"     ". 增加Ignore注解,忽略Javabean字段,不进行转换. 用模板生成文件支持自定义起止标签. -- Gitee From 7be9c114b92ef9d19117a5819af8582162b9f8e3 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Mon, 22 Mar 2021 13:16:25 +0800 Subject: [PATCH 049/124] support different type muli-Ds at same time. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b3d3513..adf74f3 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,7 @@ no Javabean, use map to set the entity information that needs to be transformed support read excel(*.xls,*.xlsx), converting data into List and importing them into database(bee-ext). 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. -- Gitee From 6d7a42818a0ab61b305a432fcebb05df0420bd81 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Mon, 22 Mar 2021 23:01:47 +0800 Subject: [PATCH 050/124] support use different type database at same time. --- .../java/org/teasoft/bee/osql/PreparedSql.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/org/teasoft/bee/osql/PreparedSql.java b/src/main/java/org/teasoft/bee/osql/PreparedSql.java index 7145c74..126e454 100644 --- a/src/main/java/org/teasoft/bee/osql/PreparedSql.java +++ b/src/main/java/org/teasoft/bee/osql/PreparedSql.java @@ -29,6 +29,12 @@ import java.util.Map; *
若没有使用占位符,则传入空数组或Map即可. *

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. + * * @author Kingstar * @since 1.0

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

@@ -174,6 +180,9 @@ public interface PreparedSql { /** * 查询并将每一行结果转成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 * @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). @@ -196,6 +205,9 @@ public interface PreparedSql { /** * 查询并将每一行结果转成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 * @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). @@ -216,6 +228,9 @@ public interface PreparedSql { /** * 用可带问号的占位语句查询结果,并以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). @@ -236,6 +251,9 @@ public interface PreparedSql { /** * 查询结果,并以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 * @param start 开始下标(从0或1开始,eg:MySQL是0,Oracle是1). start index,min value is 0 or 1(eg:MySQL is 0,Oracle is 1). -- Gitee From 5ed62cf7b6c25a0921261a18881f1427c9725f26 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Mon, 22 Mar 2021 23:01:51 +0800 Subject: [PATCH 051/124] support use different type database at same time. --- README_CN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README_CN.md b/README_CN.md index 532633f..ec9c100 100644 --- a/README_CN.md +++ b/README_CN.md @@ -67,7 +67,7 @@ Condition 添加方法:opWithField,setWithField 支持像:field1=field2的表达 支持读取Excel(*.xls,*.xlsx),并将数据转成List,且导入到数据库(bee-ext). 多表关联查询支持多个关联条件. 多个ORM操作使用同一个Connection. -支持同时使用多种类型数据库的数据源. +支持同时使用不同数据库(多个数据源). 支持长度大于0空字符串忽略处理,如"     ". 增加Ignore注解,忽略Javabean字段,不进行转换. 用模板生成文件支持自定义起止标签. -- Gitee From 9f8247fbafbe80ad9803fbc1d1ef0347dbe236a7 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Tue, 23 Mar 2021 10:41:12 +0800 Subject: [PATCH 052/124] add method setDynamicParameter in SuidRich for coding programming --- src/main/java/org/teasoft/bee/osql/Suid.java | 4 ++-- src/main/java/org/teasoft/bee/osql/SuidRich.java | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/teasoft/bee/osql/Suid.java b/src/main/java/org/teasoft/bee/osql/Suid.java index 33766d8..0a71729 100644 --- a/src/main/java/org/teasoft/bee/osql/Suid.java +++ b/src/main/java/org/teasoft/bee/osql/Suid.java @@ -105,8 +105,8 @@ public interface Suid { /** * 为动态表名、实体名参数设置值.set dynamic parameter for dynamic table & entity name - *
本方法的调用要早于Suid(select,update,insert,delete)方法. - *
This method is called earlier than the Suid(select, update, insert, delete) method. + *
本方法的调用要早于select,update,insert,delete等方法. + *
This method is called earlier than the select, update, insert, delete methods. * @param para parameter name * @param value parameter value * @return Suid diff --git a/src/main/java/org/teasoft/bee/osql/SuidRich.java b/src/main/java/org/teasoft/bee/osql/SuidRich.java index e3364f3..e082452 100644 --- a/src/main/java/org/teasoft/bee/osql/SuidRich.java +++ b/src/main/java/org/teasoft/bee/osql/SuidRich.java @@ -529,5 +529,19 @@ public interface SuidRich extends Suid { * @since 1.8 */ public int update(T entity,Condition condition); + + /** + * 为动态表名、实体名参数设置值.set dynamic parameter for dynamic table & entity name + *
本方法的调用要早于select,update,insert,delete等方法. + *
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 + * @param value parameter value + * @return SuidRich + * @since 1.9 + */ + public SuidRich setDynamicParameter(String para, String value); } -- Gitee From 4eb0aeda5d9a57455cde114704453708c0c98753 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Tue, 23 Mar 2021 10:41:32 +0800 Subject: [PATCH 053/124] add method setDynamicParameter in SuidRich for coding programming --- .../bee/osql/service/ObjSQLRichAbstractServiceImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) 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 cbd0b30..1f38fb2 100644 --- a/src/main/java/org/teasoft/bee/osql/service/ObjSQLRichAbstractServiceImpl.java +++ b/src/main/java/org/teasoft/bee/osql/service/ObjSQLRichAbstractServiceImpl.java @@ -23,6 +23,7 @@ import org.teasoft.bee.osql.Condition; import org.teasoft.bee.osql.FunctionType; import org.teasoft.bee.osql.IncludeType; import org.teasoft.bee.osql.OrderType; +import org.teasoft.bee.osql.Suid; import org.teasoft.bee.osql.SuidRich; /** @@ -312,4 +313,9 @@ public abstract class ObjSQLRichAbstractServiceImpl extends ObjSQLAbstractServic return getSuidRich().selectString(entity, condition); } + @Override + public SuidRich setDynamicParameter(String para, String value) { + //Add the business logic if need. + return getSuidRich().setDynamicParameter(para, value); + } } -- Gitee From b83b2eaf8041278b755055aafb4da80822a90a92 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Tue, 23 Mar 2021 23:14:51 +0800 Subject: [PATCH 054/124] update DatabaseConst --- .../java/org/teasoft/bee/osql/DatabaseConst.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/teasoft/bee/osql/DatabaseConst.java b/src/main/java/org/teasoft/bee/osql/DatabaseConst.java index 7ad67d0..1af6cea 100644 --- a/src/main/java/org/teasoft/bee/osql/DatabaseConst.java +++ b/src/main/java/org/teasoft/bee/osql/DatabaseConst.java @@ -10,20 +10,21 @@ public interface DatabaseConst { String MYSQL = "MySQL"; String MariaDB = "MariaDB"; String ORACLE = "Oracle"; - String SQLSERVER = "sqlserver"; + String SQLSERVER = "Microsoft SQL Server"; String H2 = "H2"; String SQLite = "SQLite"; String PostgreSQL = "PostgreSQL"; String Cubrid = "Cubrid"; - String DB2 = "DB2"; - String Derby = "Derby"; + String DB2400 = "DB2 UDB for AS/400"; + String DB2 = "DB2"; //todo + String Derby = "Apache Derby"; String Firebird = "Firebird"; String FrontBase = "FrontBase"; - String HSQL = "HSQL"; - String Informix = "Informix"; + String HSQL = "HSQL Database Engine"; + String Informix = "Informix Dynamic Server"; String Ingres = "Ingres"; String JDataStore = "JDataStore"; String Mckoi = "Mckoi"; @@ -31,7 +32,7 @@ public interface DatabaseConst { String Pointbase = "Pointbase"; String SAPDB = "SAPDB"; - String Sybase = "Sybase"; + String Sybase = "Sybase SQL Server"; String Teradata = "Teradata"; String TimesTen = "TimesTen"; -- Gitee From 8b8d8b436129f6bbc624a1e8a9b2c7a2b2dc6984 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Wed, 24 Mar 2021 19:17:12 +0800 Subject: [PATCH 055/124] MoreTable add method setDynamicParameter --- src/main/java/org/teasoft/bee/osql/MoreTable.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/org/teasoft/bee/osql/MoreTable.java b/src/main/java/org/teasoft/bee/osql/MoreTable.java index 5fcbf54..91ba8ce 100644 --- a/src/main/java/org/teasoft/bee/osql/MoreTable.java +++ b/src/main/java/org/teasoft/bee/osql/MoreTable.java @@ -114,5 +114,16 @@ public interface MoreTable { * @return 返回可包含多个实体(多条记录)的list. return list can contain more than one entity */ public List select(T entity, Condition condition); + + /** + * 为动态表名、实体名参数设置值.set dynamic parameter for dynamic table & entity name + *
本方法的调用要早于select等方法. + *
This method is called earlier than the select methods. + * @param para parameter name + * @param value parameter value + * @return MoreTable + * @since 1.9 + */ + public MoreTable setDynamicParameter(String para,String value); } -- Gitee From 922700f37c3224654e7e0d6aa293e776f5d31730 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 25 Mar 2021 13:59:19 +0800 Subject: [PATCH 056/124] test V1.9 with well-known and major database --- src/test/java/org/teasoft/bee/BeeExam.java | 113 +++++++++++---------- 1 file changed, 62 insertions(+), 51 deletions(-) diff --git a/src/test/java/org/teasoft/bee/BeeExam.java b/src/test/java/org/teasoft/bee/BeeExam.java index 12f586c..fbbb12c 100644 --- a/src/test/java/org/teasoft/bee/BeeExam.java +++ b/src/test/java/org/teasoft/bee/BeeExam.java @@ -28,6 +28,60 @@ public class BeeExam { @Test public void test(){ +// 测试用例请查看工程:bee-exam +// 以下任意一个地址: +// https://gitee.com/automvc/bee-exam +// https://github.com/automvc/bee-exam +// +// 让开发爱上测试,从Bee开始! + + boolean isFinished=false; + + System.out.println("测试用例请查看工程:bee-exam"); + System.out.println("以下任意一个地址:"); + System.out.println("https://gitee.com/automvc/bee-exam"); + System.out.println("https://github.com/automvc/bee-exam"); + System.out.println(""); + System.out.println("让开发爱上测试,从Bee开始!"); + System.out.println(""); + + System.out.println("------------------------"); + System.out.println(""); +// test case see new project:bee-exam +// url as below: +// https://github.com/automvc/bee-exam +// https://gitee.com/automvc/bee-exam +// +// Let developers like test, starting with Bee! + + System.out.println("test case see new project:bee-exam"); + System.out.println("url as below:"); + System.out.println("https://github.com/automvc/bee-exam"); + System.out.println("https://gitee.com/automvc/bee-exam"); + System.out.println(""); + System.out.println("Let developers like test, starting with Bee!"); + + isFinished=true; + Assert.assertEquals(isFinished,true); + + +// 2021-03-20 (yyyy-MM-dd) +// Instructions Counters +// Element Coverage +// Bee 91.6% +// Honey 65.6% +// +// Method Counters +// Element Coverage +// Bee 88.0% +// Honey 70.3% +// +// Type Counters +// Element Coverage +// Bee 97.0% +// Honey 86.3% + + // bee-exam last update time:2020-06-13 13:14 (yyyy-MM-dd HH:mm) //add multi-DataSource support(Write/Read, only Split Database) // bee-exam last update time:2020-06-27 16:40 (yyyy-MM-dd HH:mm) @@ -70,58 +124,15 @@ public class BeeExam { // bee-exam(v1.9)-cache(Oracle)-2021-03-20 20.02.02.758.txt // bee-exam(v1.9)-normal(MySQL)-2021-03-20 23.10.06.324.txt // bee-exam(v1.9)-cache(MySQL)-2021-03-20 23.10.16.346.txt +// bee-exam(v1.9)-normal(SQLite)-2021-03-24 22.10.08.975.txt -// 2021-03-20 (yyyy-MM-dd) -// Instructions Counters -// Element Coverage -// Bee 91.6% -// Honey 65.6% -// -// Method Counters -// Element Coverage -// Bee 88.0% -// Honey 70.3% -// -// Type Counters -// Element Coverage -// Bee 97.0% -// Honey 86.3% - -// 测试用例请查看工程:bee-exam -// 以下任意一个地址: -// https://gitee.com/automvc/bee-exam -// https://github.com/automvc/bee-exam -// -// 让开发爱上测试,从Bee开始! - - boolean isFinished=false; - - System.out.println("测试用例请查看工程:bee-exam"); - System.out.println("以下任意一个地址:"); - System.out.println("https://gitee.com/automvc/bee-exam"); - System.out.println("https://github.com/automvc/bee-exam"); - System.out.println(""); - System.out.println("让开发爱上测试,从Bee开始!"); - System.out.println(""); - - System.out.println("------------------------"); - System.out.println(""); -// test case see new project:bee-exam -// url as below: -// https://github.com/automvc/bee-exam -// https://gitee.com/automvc/bee-exam -// -// Let developers like test, starting with Bee! - - System.out.println("test case see new project:bee-exam"); - System.out.println("url as below:"); - System.out.println("https://github.com/automvc/bee-exam"); - System.out.println("https://gitee.com/automvc/bee-exam"); - System.out.println(""); - System.out.println("Let developers like test, starting with Bee!"); - - isFinished=true; - Assert.assertEquals(isFinished,true); +// test V1.9 with well-known and major database +// bee-exam(v1.9)2021-03-25 13.10.37.514-normal(Microsoft SQL Server).txt +// bee-exam(v1.9)2021-03-25 13.14.57.616-normal(SQLite).txt +// bee-exam(v1.9)2021-03-25 13.17.51.312-normal(MySQL).txt +// bee-exam(v1.9)2021-03-25 13.20.15.761-normal(Oracle).txt +// bee-exam(v1.9)2021-03-25 13.23.08.180-normal(H2).txt +// bee-exam(v1.9)2021-03-25 13.25.51.23-normal(PostgreSQL).txt } } -- Gitee From 3ba5937b82adc4b2ab660e1d714c6bd6d834edf3 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 25 Mar 2021 13:59:25 +0800 Subject: [PATCH 057/124] test V1.9 with well-known and major database --- src/test/java/org/teasoft/bee/change-log.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test/java/org/teasoft/bee/change-log.txt b/src/test/java/org/teasoft/bee/change-log.txt index ac32021..c3dff93 100644 --- a/src/test/java/org/teasoft/bee/change-log.txt +++ b/src/test/java/org/teasoft/bee/change-log.txt @@ -82,3 +82,13 @@ bee-exam(v1.9)-normal(Oracle)-2021-03-20 20.01.44.213.txt bee-exam(v1.9)-cache(Oracle)-2021-03-20 20.02.02.758.txt bee-exam(v1.9)-normal(MySQL)-2021-03-20 23.10.06.324.txt bee-exam(v1.9)-cache(MySQL)-2021-03-20 23.10.16.346.txt +bee-exam(v1.9)-normal(SQLite)-2021-03-24 22.10.08.975.txt + +test V1.9 with well-known and major database +bee-exam(v1.9)2021-03-25 13.10.37.514-normal(Microsoft SQL Server).txt +bee-exam(v1.9)2021-03-25 13.14.57.616-normal(SQLite).txt +bee-exam(v1.9)2021-03-25 13.17.51.312-normal(MySQL).txt +bee-exam(v1.9)2021-03-25 13.20.15.761-normal(Oracle).txt +bee-exam(v1.9)2021-03-25 13.23.08.180-normal(H2).txt +bee-exam(v1.9)2021-03-25 13.25.51.23-normal(PostgreSQL).txt + -- Gitee From fcd2afa598ed313b24a0d40780c7b1754e2ae31e Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 25 Mar 2021 13:59:34 +0800 Subject: [PATCH 058/124] test V1.9 with well-known and major database --- README_CN.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README_CN.md b/README_CN.md index ec9c100..172a649 100644 --- a/README_CN.md +++ b/README_CN.md @@ -31,13 +31,13 @@ jdk1.7+ * 4.**智能化自动过滤**null和空字符串,不再需要写判断非空的代码。 * 5.**动态/任意组合**查询条件,不需要提前准备dao接口,有新的查询需求也不用修改或添加接口。 * 6.支持原生SQL排序, **原生语句分页**(不需要将全部数据查出来)。 -* 7.支持直接返回**Json**格式查询结果; 链式编程。 +* 7.支持**直接返回Json**格式查询结果; 链式编程。 * 8.支持**事务**、多个ORM操作使用同一连接、**for update**,支持**批处理**操作,支持原生SQL(**自定义sql**语句),支持**存储过程**。 * 9.支持**只查询一部分字段**。 * 10.支持面向对象方式复杂查询、**多表查询**(无n+1问题; 支持:一对一,一对多,多对一,多对多)。 * 11.**一级缓存**,概念简单,功能强大;一级缓存也可以**像JVM一样进行细粒度调优**;**智能缓存**,支持更新配置表,**不用重启**。 * 12.表名与实体名、字段名与属性名映射默认提供多种实现,且支持**自定义映射规则扩展**。 -* 13.**多种DB**支持轻松扩展(MySQL,MariaDB,Oracle,H2,SQLite,PostgreSQL等直接可用)。 +* 13.**多种DB**支持轻松扩展(MySQL,MariaDB,Oracle,H2,SQLite,PostgreSQL,SQL Server等直接可用)。 * 14.支持**读写分离**一主多从, 仅**分库**等**多数据源**模式(对以前的代码无需修改,该功能对代码是透明的,即无需额外编码),仅分库**可同时使用多种类型数据库**。 * 15.**分布式**环境下生成**连续单调递增**(在一个workerid内),**全局唯一**数字**id**;提供自然简单的分布式主键生成方式。 * 16.**支持同库分表,动态表名映射**。 -- Gitee From 38d66b96942fce142c337855c398f04318174e6a Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 25 Mar 2021 13:59:40 +0800 Subject: [PATCH 059/124] test V1.9 with well-known and major database --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index adf74f3..c95068a 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ jdk1.7+ ## Feature & Function: -**Support many Database**(MySQL,MariaDB,Oracle,H2,SQLite,PostgreSQL and so on) and easy extend。 +**Support many Database**(MySQL,MariaDB,Oracle,H2,SQLite,PostgreSQL,SQL Server and so on) and easily extend。 **V1.0** Single entity(table) Suid (select,update,insert,delete) object-oriented operation. -- Gitee From ef034ce6ec3e97ab6cc4ea61d3a8dfe13d02acdb Mon Sep 17 00:00:00 2001 From: Kingstar Date: Fri, 26 Mar 2021 23:58:24 +0800 Subject: [PATCH 060/124] update V1.9 change log --- Changed_Log_CN.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Changed_Log_CN.md b/Changed_Log_CN.md index f11bf3e..ad411f4 100644 --- a/Changed_Log_CN.md +++ b/Changed_Log_CN.md @@ -192,15 +192,17 @@ Condition 添加方法:opWithField,setWithField 支持像:field1=field2的表达 支持读取Excel(*.xls,*.xlsx),并将数据转成List,且导入到数据库(bee-ext). 多表关联查询支持多个关联条件. 多个ORM操作使用同一个Connection. +支持同时使用不同数据库(多个数据源). 支持长度大于0空字符串忽略处理,如"     ". -增加Ignore注解,忽略javabean字段,不进行转换. +增加Ignore注解,忽略Javabean字段,不进行转换. 用模板生成文件支持自定义起止标签. 完善DB连接管理. 加强代码质量. +增强链式编程:Select,Update. 更新bee.properties文件中batchSize(bee.osql.insert.batchSize). 修复多表分页查询时,同名字段在部分数据库会混淆的缺陷(oracle). 修改缺陷:update默认主键为id时,无id字段或id为null时,异常处理. 修改缺陷:cache bug. -强烈建议:使用视图时,声明视图不放缓存(因会产生脏数据). +强烈建议:使用视图时,声明视图不放缓存(因会产生脏数据). \ No newline at end of file -- Gitee From f005b9b5a5ed8a5505c43449e7d645abbdab133d Mon Sep 17 00:00:00 2001 From: Kingstar Date: Fri, 26 Mar 2021 23:58:31 +0800 Subject: [PATCH 061/124] update V1.9 change log --- Changed_Log.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Changed_Log.md b/Changed_Log.md index d84adc2..bafab31 100644 --- a/Changed_Log.md +++ b/Changed_Log.md @@ -200,15 +200,18 @@ SuidRich adjust methods selectById for unique entity and intelligently judge the enhance aggregate function cont,sum,avg,min,max,Condition add method: public Condition selectFun(FunctionType functionType,String fieldForFun); public Condition selectFun(FunctionType functionType,String fieldForFun,String alias); +Condition add method:opWithField,setWithField support like :field1=field2 no Javabean, use map to set the entity information that needs to be transformed and operate the database(select/delete record). support read excel(*.xls,*.xlsx), converting data into List and importing them into database(bee-ext). 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. +enhance chain coding:Select,Update. update batchSize(bee.osql.insert.batchSize) in bee.properties. 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. -- Gitee From ef453a16796db27e03dd348cf03e9ea72a84aaec Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sat, 27 Mar 2021 23:59:37 +0800 Subject: [PATCH 062/124] update the comment --- src/main/java/org/teasoft/bee/osql/Condition.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/teasoft/bee/osql/Condition.java b/src/main/java/org/teasoft/bee/osql/Condition.java index d5fe4b9..4284a09 100644 --- a/src/main/java/org/teasoft/bee/osql/Condition.java +++ b/src/main/java/org/teasoft/bee/osql/Condition.java @@ -111,7 +111,7 @@ public interface Condition extends ConditionAssistant { public Condition between(String field, Number low, Number high); /** - * + * not between * @param field * @param low * @param high @@ -120,7 +120,7 @@ public interface Condition extends ConditionAssistant { public Condition notBetween(String field, Number low, Number high); /** - * + * between * @param field * @param low * @param high @@ -129,7 +129,7 @@ public interface Condition extends ConditionAssistant { public Condition between(String field, String low, String high); /** - * + * not between * @param field * @param low * @param high @@ -138,7 +138,7 @@ public interface Condition extends ConditionAssistant { public Condition notBetween(String field, String low, String high); /** - * + * group by * @param field * @return Condition */ @@ -156,6 +156,7 @@ public interface Condition extends ConditionAssistant { // .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 实体字段,会被命名转换(如果需要). @@ -166,6 +167,7 @@ public interface Condition extends ConditionAssistant { public Condition having(FunctionType functionType, String field, Op Op, Number value); /** + * order by * eg: orderBy("price")-->order by price * @param field 用于排序的字段名.field name. * @return Condition @@ -173,6 +175,7 @@ public interface Condition extends ConditionAssistant { 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) -- Gitee From 92588aa59a44d8d3a99b17bc19dff35906b69d9a Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sun, 28 Mar 2021 00:21:05 +0800 Subject: [PATCH 063/124] update comment for MapSuid --- src/main/java/org/teasoft/bee/osql/MapSuid.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/teasoft/bee/osql/MapSuid.java b/src/main/java/org/teasoft/bee/osql/MapSuid.java index ba0b975..5f73388 100644 --- a/src/main/java/org/teasoft/bee/osql/MapSuid.java +++ b/src/main/java/org/teasoft/bee/osql/MapSuid.java @@ -41,12 +41,13 @@ public interface MapSuid { /** * 使用MapSql查询数据.Use MapSql to select data. * @param mapSql MapSql instance - * @return Json格式的多行记录.multi-line record in JSON format. + * @return Json格式的多行记录.multi-line record in Json format. */ public String selectJson(MapSql mapSql); /** * 使用MapSql查询数据.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. @@ -55,6 +56,7 @@ public interface MapSuid { /** * 使用MapSql查询数据.Use MapSql to select data. + *
one map element as : field-name:value * @param mapSql MapSql instance * @return 包装在一个Map中的一行数据.returns a row of data wrapped in a map. */ -- Gitee From 1f459320ed03ca193eb3e7198e8a2cd79ba570f5 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Mon, 29 Mar 2021 11:33:41 +0800 Subject: [PATCH 064/124] update the demo desc --- README_CN.md | 3 ++- src/main/java/org/teasoft/bee/osql/BeeAbstractFactory.java | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README_CN.md b/README_CN.md index 172a649..ba680cf 100644 --- a/README_CN.md +++ b/README_CN.md @@ -249,7 +249,8 @@ OrdersService.java 注:如果还没有bee.properties文件,可以自己新建一个. 也可以配置数据源(此处只是一个例子). -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.username = root diff --git a/src/main/java/org/teasoft/bee/osql/BeeAbstractFactory.java b/src/main/java/org/teasoft/bee/osql/BeeAbstractFactory.java index fd2b3f6..a79943b 100644 --- a/src/main/java/org/teasoft/bee/osql/BeeAbstractFactory.java +++ b/src/main/java/org/teasoft/bee/osql/BeeAbstractFactory.java @@ -17,7 +17,6 @@ package org.teasoft.bee.osql; -import java.sql.Connection; import java.util.Map; import javax.sql.DataSource; -- Gitee From 0f52ba8c6cad59f0d4088ed26fe208188080b7e0 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Mon, 29 Mar 2021 11:33:47 +0800 Subject: [PATCH 065/124] update the demo desc --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c95068a..7a1dc3c 100644 --- a/README.md +++ b/README.md @@ -290,7 +290,8 @@ 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.username = root -- Gitee From 071267fbcf46f1e9bb3b64abf85eb1f28698075d Mon Sep 17 00:00:00 2001 From: Kingstar Date: Tue, 30 Mar 2021 22:42:55 +0800 Subject: [PATCH 066/124] clean the import --- .../teasoft/bee/osql/service/ObjSQLRichAbstractServiceImpl.java | 1 - 1 file changed, 1 deletion(-) 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 1f38fb2..2db563e 100644 --- a/src/main/java/org/teasoft/bee/osql/service/ObjSQLRichAbstractServiceImpl.java +++ b/src/main/java/org/teasoft/bee/osql/service/ObjSQLRichAbstractServiceImpl.java @@ -23,7 +23,6 @@ import org.teasoft.bee.osql.Condition; import org.teasoft.bee.osql.FunctionType; import org.teasoft.bee.osql.IncludeType; import org.teasoft.bee.osql.OrderType; -import org.teasoft.bee.osql.Suid; import org.teasoft.bee.osql.SuidRich; /** -- Gitee From f16d31dd90ac012d25134fdf8509e8af1f6cfa81 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Wed, 31 Mar 2021 23:09:55 +0800 Subject: [PATCH 067/124] update the api --- src/main/java/org/teasoft/bee/osql/Condition.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/teasoft/bee/osql/Condition.java b/src/main/java/org/teasoft/bee/osql/Condition.java index 4284a09..61bad92 100644 --- a/src/main/java/org/teasoft/bee/osql/Condition.java +++ b/src/main/java/org/teasoft/bee/osql/Condition.java @@ -184,6 +184,7 @@ public interface Condition extends ConditionAssistant { 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. -- Gitee From 7e8e8bd22e82c15b11c58e841c45185b14609c2d Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 1 Apr 2021 23:52:17 +0800 Subject: [PATCH 068/124] test for main database. --- src/test/java/org/teasoft/bee/BeeExam.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/test/java/org/teasoft/bee/BeeExam.java b/src/test/java/org/teasoft/bee/BeeExam.java index fbbb12c..93761d5 100644 --- a/src/test/java/org/teasoft/bee/BeeExam.java +++ b/src/test/java/org/teasoft/bee/BeeExam.java @@ -133,6 +133,13 @@ public class BeeExam { // bee-exam(v1.9)2021-03-25 13.20.15.761-normal(Oracle).txt // bee-exam(v1.9)2021-03-25 13.23.08.180-normal(H2).txt // bee-exam(v1.9)2021-03-25 13.25.51.23-normal(PostgreSQL).txt + +// bee-exam(v1.9)2021-04-01 21.32.08.537-normal(MySQL).txt +// bee-exam(v1.9)2021-04-01 21.32.24.79-normal(Oracle).txt +// bee-exam(v1.9)2021-04-01 21.32.47.917-normal(SQLite).txt +// bee-exam(v1.9)2021-04-01 21.33.04.663-normal(H2).txt +// bee-exam(v1.9)2021-04-01 21.33.08.408-normal(PostgreSQL).txt +// bee-exam(v1.9)2021-04-01 21.33.20.953-normal(Microsoft SQL Server).txt } } -- Gitee From b54f8fb7cc8ffab564e4a7f16f7f660735386878 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 1 Apr 2021 23:52:23 +0800 Subject: [PATCH 069/124] test for main database. --- src/test/java/org/teasoft/bee/change-log.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/test/java/org/teasoft/bee/change-log.txt b/src/test/java/org/teasoft/bee/change-log.txt index c3dff93..c0be608 100644 --- a/src/test/java/org/teasoft/bee/change-log.txt +++ b/src/test/java/org/teasoft/bee/change-log.txt @@ -92,3 +92,10 @@ bee-exam(v1.9)2021-03-25 13.20.15.761-normal(Oracle).txt bee-exam(v1.9)2021-03-25 13.23.08.180-normal(H2).txt bee-exam(v1.9)2021-03-25 13.25.51.23-normal(PostgreSQL).txt +bee-exam(v1.9)2021-04-01 21.32.08.537-normal(MySQL).txt +bee-exam(v1.9)2021-04-01 21.32.24.79-normal(Oracle).txt +bee-exam(v1.9)2021-04-01 21.32.47.917-normal(SQLite).txt +bee-exam(v1.9)2021-04-01 21.33.04.663-normal(H2).txt +bee-exam(v1.9)2021-04-01 21.33.08.408-normal(PostgreSQL).txt +bee-exam(v1.9)2021-04-01 21.33.20.953-normal(Microsoft SQL Server).txt + -- Gitee From 4d6d9505338808926a31ba6b709eb6a88ae1ff5e Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 1 Apr 2021 23:57:39 +0800 Subject: [PATCH 070/124] test for main database. --- src/test/java/org/teasoft/bee/BeeExam.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/test/java/org/teasoft/bee/BeeExam.java b/src/test/java/org/teasoft/bee/BeeExam.java index 93761d5..e7d0ca8 100644 --- a/src/test/java/org/teasoft/bee/BeeExam.java +++ b/src/test/java/org/teasoft/bee/BeeExam.java @@ -65,6 +65,23 @@ public class BeeExam { Assert.assertEquals(isFinished,true); +// 2021-04-01 (yyyy-MM-dd) +// Instructions Counters +// Element Coverage +// Bee 96.7% +// Honey 73.1% +// +// Method Counters +// Element Coverage +// Bee 95.5% +// Honey 75.6% +// +// Type Counters +// Element Coverage +// Bee 100.0% +// Honey 93.8% + + // 2021-03-20 (yyyy-MM-dd) // Instructions Counters // Element Coverage -- Gitee From 9b74da4e5e72448c192f8899ffc9da550d3460b8 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sat, 3 Apr 2021 23:25:03 +0800 Subject: [PATCH 071/124] insert and return Id --- src/main/java/org/teasoft/bee/osql/BeeSql.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/teasoft/bee/osql/BeeSql.java b/src/main/java/org/teasoft/bee/osql/BeeSql.java index d02a826..ea04579 100644 --- a/src/main/java/org/teasoft/bee/osql/BeeSql.java +++ b/src/main/java/org/teasoft/bee/osql/BeeSql.java @@ -105,6 +105,8 @@ public interface BeeSql { */ public int modify(String sql); + public long insertAndReturnId(String sql); + /** * 提交一批命令到数据库 * Submits a batch of commands to the database. -- Gitee From 6938d4e393ffa6b9e422cc0c43e16aec649f2202 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sat, 3 Apr 2021 23:25:10 +0800 Subject: [PATCH 072/124] insert and return Id --- src/main/java/org/teasoft/bee/osql/Suid.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/org/teasoft/bee/osql/Suid.java b/src/main/java/org/teasoft/bee/osql/Suid.java index 0a71729..6cc4c06 100644 --- a/src/main/java/org/teasoft/bee/osql/Suid.java +++ b/src/main/java/org/teasoft/bee/osql/Suid.java @@ -68,6 +68,9 @@ public interface Suid { */ public int insert(T entity); + + public long insertAndReturnId(T entity); + /** * 根据实体对象entity删除数据.According to entity object delete record. * @param entity 与表对应的实体对象,且不能为空. table's entity(do not allow null).
-- Gitee From b8dbf1c261fca915bfa08efd9f16d7982676a417 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sat, 3 Apr 2021 23:25:17 +0800 Subject: [PATCH 073/124] insert and return Id --- .../teasoft/bee/osql/service/ObjSQLAbstractServiceImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) 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 31dfc1d..a5edaf2 100644 --- a/src/main/java/org/teasoft/bee/osql/service/ObjSQLAbstractServiceImpl.java +++ b/src/main/java/org/teasoft/bee/osql/service/ObjSQLAbstractServiceImpl.java @@ -36,6 +36,12 @@ public abstract class ObjSQLAbstractServiceImpl implements ObjSQLService { //Add the business logic if need. return getSuid().insert(entity); } + + @Override + public long insertAndReturnId(T entity) { + //Add the business logic if need. + return getSuid().insertAndReturnId(entity); + } @Override public List select(T entity) { -- Gitee From 8789f7a2a14b3426056caf0101e926f3b0bb16a5 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sat, 3 Apr 2021 23:45:24 +0800 Subject: [PATCH 074/124] insert and return id;replace old id when genid --- src/test/java/org/teasoft/bee/BeeExam.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/test/java/org/teasoft/bee/BeeExam.java b/src/test/java/org/teasoft/bee/BeeExam.java index e7d0ca8..61d3e87 100644 --- a/src/test/java/org/teasoft/bee/BeeExam.java +++ b/src/test/java/org/teasoft/bee/BeeExam.java @@ -157,6 +157,14 @@ public class BeeExam { // bee-exam(v1.9)2021-04-01 21.33.04.663-normal(H2).txt // bee-exam(v1.9)2021-04-01 21.33.08.408-normal(PostgreSQL).txt // bee-exam(v1.9)2021-04-01 21.33.20.953-normal(Microsoft SQL Server).txt + +// bee-exam(v1.9)2021-04-03 21.55.13.02-normal(MySQL).txt +// bee-exam(v1.9)2021-04-03 21.55.27.357-normal(Oracle).txt +// bee-exam(v1.9)2021-04-03 21.55.51.369-normal(SQLite).txt +// bee-exam(v1.9)2021-04-03 21.56.05.780-normal(H2).txt +// bee-exam(v1.9)2021-04-03 21.56.10.191-normal(PostgreSQL).txt +// bee-exam(v1.9)2021-04-03 21.56.22.701-normal(Microsoft SQL Server).txt +// bee-exam(v1.9)2021-04-03 21.56.30.119-cache(MySQL).txt } } -- Gitee From 2ab1dd24e580a67e6b6597b7ce3241b7b53edb81 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sat, 3 Apr 2021 23:45:29 +0800 Subject: [PATCH 075/124] insert and return id;replace old id when genid --- src/test/java/org/teasoft/bee/change-log.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/test/java/org/teasoft/bee/change-log.txt b/src/test/java/org/teasoft/bee/change-log.txt index c0be608..a6d659d 100644 --- a/src/test/java/org/teasoft/bee/change-log.txt +++ b/src/test/java/org/teasoft/bee/change-log.txt @@ -99,3 +99,10 @@ bee-exam(v1.9)2021-04-01 21.33.04.663-normal(H2).txt bee-exam(v1.9)2021-04-01 21.33.08.408-normal(PostgreSQL).txt bee-exam(v1.9)2021-04-01 21.33.20.953-normal(Microsoft SQL Server).txt +bee-exam(v1.9)2021-04-03 21.55.13.02-normal(MySQL).txt +bee-exam(v1.9)2021-04-03 21.55.27.357-normal(Oracle).txt +bee-exam(v1.9)2021-04-03 21.55.51.369-normal(SQLite).txt +bee-exam(v1.9)2021-04-03 21.56.05.780-normal(H2).txt +bee-exam(v1.9)2021-04-03 21.56.10.191-normal(PostgreSQL).txt +bee-exam(v1.9)2021-04-03 21.56.22.701-normal(Microsoft SQL Server).txt +bee-exam(v1.9)2021-04-03 21.56.30.119-cache(MySQL).txt -- Gitee From 996bd3d7f0a13a241350de9f0fca909697582083 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Mon, 5 Apr 2021 21:45:18 +0800 Subject: [PATCH 076/124] =?UTF-8?q?update=20the=20api=20for=20method=20get?= =?UTF-8?q?RangeId(int=20size=EF=BC=89=20of=20GenId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/teasoft/bee/distribution/GenId.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/org/teasoft/bee/distribution/GenId.java b/src/main/java/org/teasoft/bee/distribution/GenId.java index 79310f3..d4216bf 100644 --- a/src/main/java/org/teasoft/bee/distribution/GenId.java +++ b/src/main/java/org/teasoft/bee/distribution/GenId.java @@ -113,6 +113,16 @@ public interface GenId { /** * 一次获取一段号码,返回一个批次可用号码的最小值和最大值,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算法不会出现以上两种问题. + *
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. * @return return the array of long. array[0]=min,array[1]=max. */ -- Gitee From 23674960a5820fca975f0887d7c55f81bf177311 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Mon, 5 Apr 2021 21:53:18 +0800 Subject: [PATCH 077/124] =?UTF-8?q?update=20the=20api=20for=20method=20get?= =?UTF-8?q?RangeId(int=20size=EF=BC=89=20of=20GenId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/teasoft/bee/distribution/GenId.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/teasoft/bee/distribution/GenId.java b/src/main/java/org/teasoft/bee/distribution/GenId.java index d4216bf..4210a70 100644 --- a/src/main/java/org/teasoft/bee/distribution/GenId.java +++ b/src/main/java/org/teasoft/bee/distribution/GenId.java @@ -99,7 +99,6 @@ package org.teasoft.bee.distribution; * 考虑到2019年双11的峰值不超过55万笔/秒, 因此419w/s这个值已可以满足此苛刻要求;采用testSpeedLimit()检测平均值不超过419w/s这个值即可,而且在空闲时 * 段省下的ID号,还可以在高峰时使用。 * - * * @author Kingstar * @since 1.7.2 */ -- Gitee From 382f86d3c1b90f12bb27af6110eb415b343e5436 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Tue, 6 Apr 2021 23:25:44 +0800 Subject: [PATCH 078/124] Suid add method insertAndReturnId; fixed bug about getRangeId(int sizeOfIds) of GenId --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 7a1dc3c..4845ba2 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,7 @@ enhance SuidRich function, SuidRich add method: public int count(T entity); public int count(T entity, Condition condition); SuidRich adjust methods selectById for unique entity and intelligently judge the Javabean id type of string id parameter. +Suid add method insertAndReturnId. enhance aggregate function cont,sum,avg,min,max,Condition add method: public Condition selectFun(FunctionType functionType,String fieldForFun); public Condition selectFun(FunctionType functionType,String fieldForFun,String alias); @@ -122,6 +123,7 @@ update batchSize(bee.osql.insert.batchSize) in bee.properties. 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. when entity is view(not table), recommend put in bee.osql.cache.never(bee.properties). ## [Function Detail](../../../bee/blob/master/Changed_Log.md) -- Gitee From a5bc619f54a9f7fed400f5a67fa1b6267dd018ee Mon Sep 17 00:00:00 2001 From: Kingstar Date: Tue, 6 Apr 2021 23:26:40 +0800 Subject: [PATCH 079/124] Suid add method insertAndReturnId; fixed bug about getRangeId(int sizeOfIds) of GenId --- README_CN.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README_CN.md b/README_CN.md index ba680cf..0e5dd40 100644 --- a/README_CN.md +++ b/README_CN.md @@ -59,6 +59,7 @@ SuidRich新增支持List参数的批量插入方法. public int count(T entity); public int count(T entity, Condition condition); SuidRich调整selectById方法且String类型参数的id智能识别Javabean的id类型. +Suid新增insertAndReturnId方法. 加强聚合函数cont,sum,avg,min,max功能,Condition增加方法: public Condition selectFun(FunctionType functionType,String fieldForFun); public Condition selectFun(FunctionType functionType,String fieldForFun,String alias); @@ -78,6 +79,7 @@ Condition 添加方法:opWithField,setWithField 支持像:field1=field2的表达 修复多表分页查询时,同名字段在部分数据库会混淆的缺陷(oracle). 修改缺陷:update默认主键为id时,无id字段或id为null时,异常处理. 修改缺陷:cache bug. +修改缺陷:有关GenId的 getRangeId(int sizeOfIds)方法. 强烈建议:使用视图时,声明视图不放缓存(因会产生脏数据). ## [详细完整功能介绍](../../../bee/blob/master/Changed_Log_CN.md) -- Gitee From 96249de5128117eb87eda6838569fb2e4983f6f8 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Wed, 7 Apr 2021 00:15:26 +0800 Subject: [PATCH 080/124] update the FAQ -17 --- FAQ_CN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FAQ_CN.md b/FAQ_CN.md index c4a735c..eee7efd 100644 --- a/FAQ_CN.md +++ b/FAQ_CN.md @@ -164,7 +164,7 @@ A: Bee文件小。bee V1.8 jar files 仅217k. 而且性能也接近JDBC的性能 Q: 如何自动填日期字段? -A: Bee默认不支持是null或空的字段; +A: Bee默认不解析是null或空的字段; 当Javabean的日期是null时,Bee不会解析. 像mysql可以在DB端自动触发填充日期值。 18. -- Gitee From a46579487f7bb9a48b29c60c5cf2be543119006d Mon Sep 17 00:00:00 2001 From: aiteasoft Date: Thu, 8 Apr 2021 12:26:27 +0800 Subject: [PATCH 081/124] update src/main/java/org/teasoft/bee/osql/CallableSql.java. --- src/main/java/org/teasoft/bee/osql/CallableSql.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/teasoft/bee/osql/CallableSql.java b/src/main/java/org/teasoft/bee/osql/CallableSql.java index ceae95a..007c8d9 100644 --- a/src/main/java/org/teasoft/bee/osql/CallableSql.java +++ b/src/main/java/org/teasoft/bee/osql/CallableSql.java @@ -38,7 +38,7 @@ public interface CallableSql { /** * - * @param callSql procedure sql + * @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. */ @@ -46,7 +46,7 @@ public interface CallableSql { /** * - * @param callSql procedure sql + * @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. * @since 1.1 @@ -54,10 +54,9 @@ public interface CallableSql { public String selectJson(String callSql,Object preValues[]); -// int executeUpdate() /** * - * @param callSql procedure sql + * @param callSql procedure sql,eg: procedure_name(?) * @param preValues parameter,just support In type; 只支持in类型的参数 * @return 成功操作的记录行数. the number of affected successfully records. */ @@ -65,7 +64,7 @@ public interface CallableSql { /** * 返回CallableStatement对象以便可以设置in,out,inout参数.可方便调用JDBC底层的方法 - * @param callSql procedure sql + * @param callSql procedure sql,eg: procedure_name(?) * @return CallableStatement. */ public CallableStatement getCallableStatement(String callSql); -- Gitee From d67980818cbfdf90986bf58bac6fe020a34213d4 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 8 Apr 2021 18:57:40 +0800 Subject: [PATCH 082/124] close one method --- src/main/java/org/teasoft/bee/osql/ObjToSQLRich.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/teasoft/bee/osql/ObjToSQLRich.java b/src/main/java/org/teasoft/bee/osql/ObjToSQLRich.java index 729e6c4..19b8cf9 100644 --- a/src/main/java/org/teasoft/bee/osql/ObjToSQLRich.java +++ b/src/main/java/org/teasoft/bee/osql/ObjToSQLRich.java @@ -46,7 +46,7 @@ public interface ObjToSQLRich extends ObjToSQL { public String toUpdateSQL(T entity, IncludeType includeType); public String[] toInsertSQL(T[] entity); - public String[] toInsertSQL(T[] entity,int batchSize); +// public String[] toInsertSQL(T[] entity,int batchSize); public String[] toInsertSQL(T[] entity,String excludeFields); public String[] toInsertSQL(T[] entity,int batchSize,String excludeFields); -- Gitee From 894f5fde41cf280332cbd9be8747e70677f57213 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 15 Apr 2021 08:56:28 +0800 Subject: [PATCH 083/124] the field use in Condition for where part, also will parse in the entity by default. --- src/main/java/org/teasoft/bee/osql/MoreObjToSQL.java | 2 +- src/main/java/org/teasoft/bee/osql/MoreTable.java | 2 +- src/main/java/org/teasoft/bee/osql/Suid.java | 4 ++-- src/main/java/org/teasoft/bee/osql/SuidRich.java | 12 ++++++------ 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/teasoft/bee/osql/MoreObjToSQL.java b/src/main/java/org/teasoft/bee/osql/MoreObjToSQL.java index 74f2dfa..029f448 100644 --- a/src/main/java/org/teasoft/bee/osql/MoreObjToSQL.java +++ b/src/main/java/org/teasoft/bee/osql/MoreObjToSQL.java @@ -31,7 +31,7 @@ public interface MoreObjToSQL { /** * 根据entity和Condition转换成sql语句 * @param entity 实体类对象,且不能为空. table's entity(do not allow null). - * @param condition 默认有值的字段会转成field=value的形式,其它形式可通过condition指定.condition使用过的字段,默认情况不会再处理. + * @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. */ diff --git a/src/main/java/org/teasoft/bee/osql/MoreTable.java b/src/main/java/org/teasoft/bee/osql/MoreTable.java index 91ba8ce..6c3f072 100644 --- a/src/main/java/org/teasoft/bee/osql/MoreTable.java +++ b/src/main/java/org/teasoft/bee/osql/MoreTable.java @@ -108,7 +108,7 @@ public interface MoreTable { /** * 根据实体对象和Condition查询数据.Select the records according to entity and condition. * @param entity 与表对应的实体对象,且不能为空. table's entity(do not allow null).
- * @param condition entity默认有值的字段会转成field=value的形式,其它形式可通过condition指定.condition使用过的字段,默认情况不会再处理.
+ * @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 diff --git a/src/main/java/org/teasoft/bee/osql/Suid.java b/src/main/java/org/teasoft/bee/osql/Suid.java index 6cc4c06..1f91370 100644 --- a/src/main/java/org/teasoft/bee/osql/Suid.java +++ b/src/main/java/org/teasoft/bee/osql/Suid.java @@ -86,7 +86,7 @@ public interface Suid { * 根据实体对象和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指定.condition使用过的字段,默认情况不会再处理.
+ * @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. @@ -98,7 +98,7 @@ public interface Suid { * 根据实体对象和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指定.condition使用过的字段,默认情况不会再处理.
+ * @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 成功删除的记录行数. the number of deleted record(s) successfully. diff --git a/src/main/java/org/teasoft/bee/osql/SuidRich.java b/src/main/java/org/teasoft/bee/osql/SuidRich.java index e082452..7bdf27f 100644 --- a/src/main/java/org/teasoft/bee/osql/SuidRich.java +++ b/src/main/java/org/teasoft/bee/osql/SuidRich.java @@ -154,7 +154,7 @@ public interface SuidRich extends Suid { * @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方法将被忽略.will ignore the condition's selectFun method. + *
在此,condition的selectFun方法将被忽略.here will ignore the condition's selectFun method. * @return 一个函数查询的结果.one function result. * @since 1.9 */ @@ -411,7 +411,7 @@ public interface SuidRich extends Suid { * @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指定.condition使用过的字段,默认情况不会再处理.
+ * @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. @@ -426,7 +426,7 @@ public interface SuidRich extends Suid { * @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指定.condition使用过的字段,默认情况不会再处理.
+ * @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格式的字符串. @@ -440,7 +440,7 @@ public interface SuidRich extends Suid { * 根据实体对象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指定.condition使用过的字段,默认情况不会再处理.
+ * @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格式的字符串. @@ -502,7 +502,7 @@ public interface SuidRich extends Suid { /** * 更新记录,且可以指定需要更新的字段,高级条件可通过Condition参数设置.Update record, can list update fields. * @param entity 实体类对象,不能为空.table's entity(do not allow null). - * entity默认有值的字段会转成field=value的形式,其它形式可通过condition指定.condition中op,between等方法设置的转换到where中的字段,默认情况不会再处理.
+ * 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表达式. @@ -521,7 +521,7 @@ public interface SuidRich extends Suid { * 更新记录,高级条件可通过Condition参数设置 Update record,and can help with Condition. *
当SQL update的set表达式通过Condition定义时,可以不用再指定set使用的字段. * @param entity 实体类对象,不能为空.table's entity(do not allow null). - * entity默认有值的字段会转成field=value的形式,其它形式可通过condition指定.condition中op,between等方法设置的转换到where中的字段,默认情况不会再处理.
+ * 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 condition * 若condition没有设置IncludeType,默认过滤NULL和空字符串(但condition中op,between,notBetween方法设置的字段,不受includeType的值影响.) -- Gitee From 245defe94b1fdc49cc654d1a762a8ae8bbab3833 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 15 Apr 2021 22:20:56 +0800 Subject: [PATCH 084/124] support select Distinct Field in Condition --- src/main/java/org/teasoft/bee/osql/Condition.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/teasoft/bee/osql/Condition.java b/src/main/java/org/teasoft/bee/osql/Condition.java index 61bad92..b50463d 100644 --- a/src/main/java/org/teasoft/bee/osql/Condition.java +++ b/src/main/java/org/teasoft/bee/osql/Condition.java @@ -274,6 +274,11 @@ public interface Condition extends ConditionAssistant { */ public Condition selectField(String fieldList); + + public Condition selectDistinctField(String fieldName); + + public Condition selectDistinctField(String fieldName, String alias); + /** * 设置使用函数查询结果.set select result with function. *
eg: condition.selectFun(FunctionType.COUNT, "*");-->count(*) @@ -282,7 +287,7 @@ public interface Condition extends ConditionAssistant { * @return Condition * @since 1.9 */ - public Condition selectFun(FunctionType functionType,String fieldForFun); + public Condition selectFun(FunctionType functionType, String fieldForFun); /** * 设置使用函数查询结果.set select result with function. @@ -293,7 +298,7 @@ public interface Condition extends ConditionAssistant { * @return Condition * @since 1.9 */ - public Condition selectFun(FunctionType functionType,String fieldForFun,String alias); + public Condition selectFun(FunctionType functionType, String fieldForFun, String alias); /** * 锁定查询的部分记录(仅用于SQL的单个表select).lock the select record with 'for update'. -- Gitee From ebda7bcc1ee1e12fd4cf490688835fcadde458b0 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 22 Apr 2021 10:15:44 +0800 Subject: [PATCH 085/124] update README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4845ba2..d479c8d 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ enhance aggregate function cont,sum,avg,min,max,Condition add method: public Condition selectFun(FunctionType functionType,String fieldForFun,String alias); Condition add method:opWithField,setWithField support like :field1=field2 no Javabean, use map to set the entity information that needs to be transformed and operate the database(select/delete record). -support read excel(*.xls,*.xlsx), converting data into List and importing them into database(bee-ext). +support read Excel(*.xls,*.xlsx), converting data into List and importing them into database(bee-ext). more table join select support more join condition. same Connection for some ORM operation. support different type muli-Ds at same time. @@ -370,10 +370,10 @@ Rapid application development: ========= **Let Java more quicker programming than php and Rails.** -**Faster development of new combinations of Java Web:** +**Faster development of new combinations for Java Web:** [Bee+Spring+SpringMVC](../../../../aiteasoft/bee-spring-springmvc) -**Faster development of new combinations of Spring Cloud microservices:** +**Faster development of new combinations for Spring Cloud microservices:** [Bee + Spring Boot](../../../bee-springboot) ... -- Gitee From f96a5aaeb09e280a1b16bfadecea1d875ec38a37 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 22 Apr 2021 10:16:14 +0800 Subject: [PATCH 086/124] add gen source --- pom.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pom.xml b/pom.xml index e62bf38..856653b 100644 --- a/pom.xml +++ b/pom.xml @@ -19,6 +19,21 @@ maven-jar-plugin 3.0.0 + + + + org.apache.maven.plugins + maven-source-plugin + 3.0.0 + + + attach-sources + + jar + + + + -- Gitee From 52d2609f76eedd8e90721b14ab501f00a9c292c5 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Fri, 23 Apr 2021 00:31:48 +0800 Subject: [PATCH 087/124] get instance use BeeFactoryHelper --- README_CN.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README_CN.md b/README_CN.md index 0e5dd40..8f09532 100644 --- a/README_CN.md +++ b/README_CN.md @@ -270,7 +270,7 @@ import java.math.BigDecimal; import java.util.List; import org.teasoft.bee.osql.Suid; -import org.teasoft.honey.osql.core.BeeFactory; +import org.teasoft.honey.osql.core.BeeFactoryHelper; /** * 查,改,增,删 Suid (select,update,insert,delete)实例 @@ -281,7 +281,7 @@ public class SuidExam { public static void main(String[] args) { - Suid suid=BeeFactory.getHoneyFactory().getSuid(); + Suid suid=BeeFactoryHelper.getSuid(); //需要先生成相应的Javabean Orders orders1=new Orders(); -- Gitee From b0e12e36a59ca04cf7d957d932f4ab1a44e19c3d Mon Sep 17 00:00:00 2001 From: Kingstar Date: Fri, 23 Apr 2021 00:31:56 +0800 Subject: [PATCH 088/124] get instance use BeeFactoryHelper --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d479c8d..0325eae 100644 --- a/README.md +++ b/README.md @@ -312,7 +312,7 @@ import java.util.List; import org.teasoft.bee.osql.BeeException; import org.teasoft.bee.osql.Suid; -import org.teasoft.honey.osql.core.BeeFactory; +import org.teasoft.honey.osql.core.BeeFactoryHelper; import org.teasoft.honey.osql.core.Logger; /** @@ -324,7 +324,7 @@ public class SuidExamEN { public static void main(String[] args) { try { - Suid suid = BeeFactory.getHoneyFactory().getSuid(); + Suid suid = BeeFactoryHelper.getSuid(); Orders orders1 = new Orders();//need gen the Javabean orders1.setId(100001L); -- Gitee From aec2bf229b640de50f09218b74747de83548c037 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Fri, 23 Apr 2021 11:00:21 +0800 Subject: [PATCH 089/124] update V1.9 new function list --- README_CN.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README_CN.md b/README_CN.md index 8f09532..b25b5f6 100644 --- a/README_CN.md +++ b/README_CN.md @@ -64,7 +64,8 @@ Suid新增insertAndReturnId方法. public Condition selectFun(FunctionType functionType,String fieldForFun); public Condition selectFun(FunctionType functionType,String fieldForFun,String alias); Condition 添加方法:opWithField,setWithField 支持像:field1=field2的表达式 -无Javabean,用map承载需要转换的实体信息,操作数据库(查询,删除数据). +Condition 添加方法:selectDistinctField,支持distinct像 select distinct(userid) from table_name +MapSuid,无Javabean,用map承载需要转换的实体信息,操作数据库(查询,删除数据). 支持读取Excel(*.xls,*.xlsx),并将数据转成List,且导入到数据库(bee-ext). 多表关联查询支持多个关联条件. 多个ORM操作使用同一个Connection. @@ -75,7 +76,9 @@ Condition 添加方法:opWithField,setWithField 支持像:field1=field2的表达 完善DB连接管理. 加强代码质量. 增强链式编程:Select,Update. -更新bee.properties文件中batchSize(bee.osql.insert.batchSize). +调整bee.properties配置信息. +整合Spring boot,提供bee-spring-boot-starter. +支持利用Javabean生成表. 修复多表分页查询时,同名字段在部分数据库会混淆的缺陷(oracle). 修改缺陷:update默认主键为id时,无id字段或id为null时,异常处理. 修改缺陷:cache bug. -- Gitee From d691a938b8234263e82b4cc1b57a78f94df300ba Mon Sep 17 00:00:00 2001 From: Kingstar Date: Fri, 23 Apr 2021 11:01:09 +0800 Subject: [PATCH 090/124] update V1.9 new function list,eg: integration with Spring boot --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0325eae..e2d2e61 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,8 @@ enhance aggregate function cont,sum,avg,min,max,Condition add method: public Condition selectFun(FunctionType functionType,String fieldForFun); public Condition selectFun(FunctionType functionType,String fieldForFun,String alias); Condition add method:opWithField,setWithField support like :field1=field2 -no Javabean, use map to set the entity information that needs to be transformed and operate the database(select/delete record). +Condition add method:selectDistinctField,support distinct as select distinct(userid) from table_name +MapSuid,no Javabean, use map to set the entity information that needs to be transformed and operate the database(select/delete record). support read Excel(*.xls,*.xlsx), converting data into List and importing them into database(bee-ext). more table join select support more join condition. same Connection for some ORM operation. @@ -119,7 +120,9 @@ support define start and end token when generate file by template. enhance DB conn management. enhance code quality. enhance chain coding:Select,Update. -update batchSize(bee.osql.insert.batchSize) in bee.properties. +adjust bee.properties. +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. -- Gitee From 22041da42bcf6d56d6662cf44619fbdd367ed0b5 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Fri, 23 Apr 2021 11:25:04 +0800 Subject: [PATCH 091/124] fixed: in jdk 11,LoggerFactory use log4j2,have exception --- README.md | 3 ++- README_CN.md | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e2d2e61..5e797f7 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ enhance aggregate function cont,sum,avg,min,max,Condition add method: public Condition selectFun(FunctionType functionType,String fieldForFun); public Condition selectFun(FunctionType functionType,String fieldForFun,String alias); Condition add method:opWithField,setWithField support like :field1=field2 -Condition add method:selectDistinctField,support distinct as select distinct(userid) from table_name +Condition add method:selectDistinctField,support distinct as select distinct(userid) from table_name MapSuid,no Javabean, use map to set the entity information that needs to be transformed and operate the database(select/delete record). support read Excel(*.xls,*.xlsx), converting data into List and importing them into database(bee-ext). more table join select support more join condition. @@ -127,6 +127,7 @@ fix the problem that the fields with the same name will be confused in some data 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). ## [Function Detail](../../../bee/blob/master/Changed_Log.md) diff --git a/README_CN.md b/README_CN.md index b25b5f6..5526804 100644 --- a/README_CN.md +++ b/README_CN.md @@ -80,9 +80,10 @@ MapSuid,无Javabean,用map承载需要转换的实体信息,操作数据库( 整合Spring boot,提供bee-spring-boot-starter. 支持利用Javabean生成表. 修复多表分页查询时,同名字段在部分数据库会混淆的缺陷(oracle). -修改缺陷:update默认主键为id时,无id字段或id为null时,异常处理. -修改缺陷:cache bug. -修改缺陷:有关GenId的 getRangeId(int sizeOfIds)方法. +修复缺陷:update默认主键为id时,无id字段或id为null时,异常处理. +修复缺陷:cache bug. +修复缺陷:有关GenId的 getRangeId(int sizeOfIds)方法. +修复缺陷:jdk 11下,LoggerFactory在配置log4j2时,报错. 强烈建议:使用视图时,声明视图不放缓存(因会产生脏数据). ## [详细完整功能介绍](../../../bee/blob/master/Changed_Log_CN.md) -- Gitee From 8ad1f4030d5f344040725d85cc13b2411f0d0a03 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Fri, 23 Apr 2021 13:48:19 +0800 Subject: [PATCH 092/124] update V1.9 function list. --- README.md | 2 +- README_CN.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5e797f7..e26657a 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ support define start and end token when generate file by template. enhance DB conn management. enhance code quality. enhance chain coding:Select,Update. -adjust bee.properties. +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. diff --git a/README_CN.md b/README_CN.md index 5526804..f5ca408 100644 --- a/README_CN.md +++ b/README_CN.md @@ -76,7 +76,7 @@ MapSuid,无Javabean,用map承载需要转换的实体信息,操作数据库( 完善DB连接管理. 加强代码质量. 增强链式编程:Select,Update. -调整bee.properties配置信息. +调整bee.properties,HoneyConfig配置信息. 整合Spring boot,提供bee-spring-boot-starter. 支持利用Javabean生成表. 修复多表分页查询时,同名字段在部分数据库会混淆的缺陷(oracle). -- Gitee From ad335431dde2ddf7f3bf9dd20ab420156cdb7829 Mon Sep 17 00:00:00 2001 From: automvc Date: Fri, 23 Apr 2021 14:13:34 +0800 Subject: [PATCH 093/124] update src/main/java/org/teasoft/bee/osql/Condition.java. add api comment for selectDistinctField --- .../java/org/teasoft/bee/osql/Condition.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/teasoft/bee/osql/Condition.java b/src/main/java/org/teasoft/bee/osql/Condition.java index b50463d..8796276 100644 --- a/src/main/java/org/teasoft/bee/osql/Condition.java +++ b/src/main/java/org/teasoft/bee/osql/Condition.java @@ -274,9 +274,23 @@ public interface Condition extends ConditionAssistant { */ public Condition selectField(String fieldList); - + /** + * 设置字段fieldName为distinct(fieldName) + * eg: selectDistinctField(fieldName) --> distinct(fieldName) + * @param fieldName 要设置为distinct的字段 + * @return Condition + * @since 1.9 + */ public Condition selectDistinctField(String fieldName); + /** + * 设置字段fieldName为distinct(fieldName) + * eg: selectDistinctField(fieldName,alias) --> distinct(fieldName) as alias + * @param fieldName 要设置为distinct的字段 + * @param alias 别名 + * @return Condition + * @since 1.9 + */ public Condition selectDistinctField(String fieldName, String alias); /** -- Gitee From 07640a32fd0c1732ae764cbd359c5c09cc319522 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Fri, 23 Apr 2021 14:27:36 +0800 Subject: [PATCH 094/124] update the Condition api comment --- src/main/java/org/teasoft/bee/osql/Condition.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/teasoft/bee/osql/Condition.java b/src/main/java/org/teasoft/bee/osql/Condition.java index 8796276..964b74f 100644 --- a/src/main/java/org/teasoft/bee/osql/Condition.java +++ b/src/main/java/org/teasoft/bee/osql/Condition.java @@ -21,6 +21,7 @@ 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部分. + *
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. * @author Kingstar * @since 1.6 -- Gitee From 085276c5bd374b21bb6c071f70d138375c544882 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sun, 25 Apr 2021 09:51:28 +0800 Subject: [PATCH 095/124] update V1.9 function list --- README_CN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README_CN.md b/README_CN.md index f5ca408..2f2592c 100644 --- a/README_CN.md +++ b/README_CN.md @@ -45,7 +45,7 @@ jdk1.7+ * 18.**无**第三方插件依赖;可零配置使用。 * 19.**性能好:接近JDBC的速度;文件小:Bee V1.8 jar 仅217k**。 辅助功能: -* 20.提供表对应的Javabean**自动生成工具**,Javaweb**后端代码**根据**模板自动生成**;能打印非占位符的**可执行sql**,方便调试。 +* 20.支持自动生成表对应的Javabean,根据Javabean创建表,Javaweb**后端代码**根据**模板自动生成**;能打印非占位符的**可执行sql**,方便调试。 * 21.支持**读取Excel**,从Excel导入数据到DB,操作简单。 ## 最新功能介绍: -- Gitee From 5082bbadf9c3bca3c4671628fc6237ccfd4d52dc Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 29 Apr 2021 11:11:45 +0800 Subject: [PATCH 096/124] add exist method --- src/main/java/org/teasoft/bee/osql/SuidRich.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/teasoft/bee/osql/SuidRich.java b/src/main/java/org/teasoft/bee/osql/SuidRich.java index 7bdf27f..1fb01a3 100644 --- a/src/main/java/org/teasoft/bee/osql/SuidRich.java +++ b/src/main/java/org/teasoft/bee/osql/SuidRich.java @@ -543,5 +543,6 @@ public interface SuidRich extends Suid { * @since 1.9 */ public SuidRich setDynamicParameter(String para, String value); - + + public boolean exist(T entity); } -- Gitee From 34c6a8f6020c0c2c4ddb2ba2430090cdfb7b6494 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 29 Apr 2021 11:12:15 +0800 Subject: [PATCH 097/124] add insert method for MapSuid. --- src/main/java/org/teasoft/bee/osql/MapSql.java | 10 +++++++++- src/main/java/org/teasoft/bee/osql/MapSuid.java | 9 +++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/teasoft/bee/osql/MapSql.java b/src/main/java/org/teasoft/bee/osql/MapSql.java index a79c7e5..666401d 100644 --- a/src/main/java/org/teasoft/bee/osql/MapSql.java +++ b/src/main/java/org/teasoft/bee/osql/MapSql.java @@ -32,12 +32,20 @@ public interface MapSql { public void put(MapSqlKey MapSqlKey, String value); /** - * 设置用于SQL中where过虑的字段信息.Set the field information used for where filtering in SQL. + * 设置用于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 */ public void put(String fieldName, Object value); +// /** +// * 用于update的Set部分 +// * @param fieldName +// * @param value +// */ +// public void putNew(String fieldName, Object value); + /** * 用于Javabean与DB转换时配置信息设置 * @param MapSqlSetting 设置的MapSqlSetting Key diff --git a/src/main/java/org/teasoft/bee/osql/MapSuid.java b/src/main/java/org/teasoft/bee/osql/MapSuid.java index 5f73388..40d4a0b 100644 --- a/src/main/java/org/teasoft/bee/osql/MapSuid.java +++ b/src/main/java/org/teasoft/bee/osql/MapSuid.java @@ -68,5 +68,14 @@ public interface MapSuid { * @return 成功删除的记录数. the numbers of delete records successfully. */ public int delete(MapSql mapSql); + + /** + * 插入并返回记录的id值. + * id值可由Bee自动生成分布式id. + * 注意:若id由DB生成,需考虑DB是否支持. + * @param mapSql + * @return 若成功,返回插入记录的id值;若失败则返回-1. + */ + public long insert(MapSql mapSql); } -- Gitee From a7297c4bf0d87eca433c5b01b740b01df5a054d3 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 29 Apr 2021 11:12:33 +0800 Subject: [PATCH 098/124] add exist method --- .../bee/osql/service/ObjSQLRichAbstractServiceImpl.java | 7 +++++++ 1 file changed, 7 insertions(+) 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 2db563e..2ce3e3c 100644 --- a/src/main/java/org/teasoft/bee/osql/service/ObjSQLRichAbstractServiceImpl.java +++ b/src/main/java/org/teasoft/bee/osql/service/ObjSQLRichAbstractServiceImpl.java @@ -317,4 +317,11 @@ public abstract class ObjSQLRichAbstractServiceImpl extends ObjSQLAbstractServic //Add the business logic if need. return getSuidRich().setDynamicParameter(para, value); } + + @Override + public boolean exist(T entity) { + //Add the business logic if need. + return getSuidRich().exist(entity); + } + } -- Gitee From 9989d7456968bc57f298a29ccb582515a5878094 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Fri, 30 Apr 2021 00:48:50 +0800 Subject: [PATCH 099/124] update api comment --- src/main/java/org/teasoft/bee/osql/MapSqlSetting.java | 2 +- src/main/java/org/teasoft/bee/osql/MapSuid.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/teasoft/bee/osql/MapSqlSetting.java b/src/main/java/org/teasoft/bee/osql/MapSqlSetting.java index 152959f..a2ef4f4 100644 --- a/src/main/java/org/teasoft/bee/osql/MapSqlSetting.java +++ b/src/main/java/org/teasoft/bee/osql/MapSqlSetting.java @@ -26,7 +26,7 @@ public enum MapSqlSetting { /** * 是否命名转换.Is naming transfer. value is 'true' or 'false',default is 'false' - * 真时,会根据配置的规则(bee.properties)如进行转换;假时不转换. + * 真时,会根据配置的规则(可在bee.properties配置)进行转换;假时不转换. * if true, will transfer by the rule (eg: bee.properties). if false,do not transfer. */ IsNamingTransfer("IsNamingTransfer") , diff --git a/src/main/java/org/teasoft/bee/osql/MapSuid.java b/src/main/java/org/teasoft/bee/osql/MapSuid.java index 40d4a0b..9286bf9 100644 --- a/src/main/java/org/teasoft/bee/osql/MapSuid.java +++ b/src/main/java/org/teasoft/bee/osql/MapSuid.java @@ -21,7 +21,7 @@ import java.util.List; import java.util.Map; /** - * 使用Map而非具体实体的数据库操作接口,默认不处理null和空字符串(因要与Suid,SuidRich风格兼容) + * 使用Map而非具体实体的数据库操作接口,默认不处理null和空字符串(与Suid,SuidRich风格兼容) *
Database operation interface using map instead of specific entity, *
the null and empty string are not handled by default. * Suid (select,update,insert,delete) @@ -72,7 +72,7 @@ public interface MapSuid { /** * 插入并返回记录的id值. * id值可由Bee自动生成分布式id. - * 注意:若id由DB生成,需考虑DB是否支持. + * 注意:若id由DB生成,需考虑DB是否支持,且对应JDBC驱动要支持返回id. * @param mapSql * @return 若成功,返回插入记录的id值;若失败则返回-1. */ -- Gitee From 481bacb735132081e9093af7d4f86a5fc1ad084a Mon Sep 17 00:00:00 2001 From: Kingstar Date: Fri, 30 Apr 2021 00:58:42 +0800 Subject: [PATCH 100/124] update V1.9 function list --- README_CN.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README_CN.md b/README_CN.md index 2f2592c..4dc87ef 100644 --- a/README_CN.md +++ b/README_CN.md @@ -58,6 +58,7 @@ SuidRich新增支持List参数的批量插入方法. public String selectWithFun(T entity, FunctionType functionType, String fieldForFun, Condition condition); public int count(T entity); public int count(T entity, Condition condition); + public boolean exist(T entity); //判断记录是否存在 SuidRich调整selectById方法且String类型参数的id智能识别Javabean的id类型. Suid新增insertAndReturnId方法. 加强聚合函数cont,sum,avg,min,max功能,Condition增加方法: @@ -65,7 +66,7 @@ Suid新增insertAndReturnId方法. public Condition selectFun(FunctionType functionType,String fieldForFun,String alias); Condition 添加方法:opWithField,setWithField 支持像:field1=field2的表达式 Condition 添加方法:selectDistinctField,支持distinct像 select distinct(userid) from table_name -MapSuid,无Javabean,用map承载需要转换的实体信息,操作数据库(查询,删除数据). +MapSuid,无需Javabean,用map承载需要转换的实体信息,操作数据库(查询,插入,删除数据). 支持读取Excel(*.xls,*.xlsx),并将数据转成List,且导入到数据库(bee-ext). 多表关联查询支持多个关联条件. 多个ORM操作使用同一个Connection. -- Gitee From b3932547aaf92d8ca31899401cc3b66a0e458d85 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Fri, 30 Apr 2021 00:58:47 +0800 Subject: [PATCH 101/124] update V1.9 function list --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e26657a..4750827 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,7 @@ enhance SuidRich function, SuidRich add method: public String selectWithFun(T entity, FunctionType functionType, String fieldForFun, Condition condition); public int count(T entity); public int count(T entity, Condition condition); + public boolean exist(T entity); //check the record whether exist in table SuidRich adjust methods selectById for unique entity and intelligently judge the Javabean id type of string id parameter. Suid add method insertAndReturnId. enhance aggregate function cont,sum,avg,min,max,Condition add method: @@ -109,7 +110,7 @@ enhance aggregate function cont,sum,avg,min,max,Condition add method: public Condition selectFun(FunctionType functionType,String fieldForFun,String alias); Condition add method:opWithField,setWithField support like :field1=field2 Condition add method:selectDistinctField,support distinct as select distinct(userid) from table_name -MapSuid,no Javabean, use map to set the entity information that needs to be transformed and operate the database(select/delete record). +MapSuid,no need Javabean, use map to set the entity information that needs to be transformed and operate the database(select/insert/delete record). support read Excel(*.xls,*.xlsx), converting data into List and importing them into database(bee-ext). more table join select support more join condition. same Connection for some ORM operation. -- Gitee From 3c338d8354f3cc99b3f0833783b8713c63c3fa17 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Fri, 30 Apr 2021 10:02:38 +0800 Subject: [PATCH 102/124] update V1.9 function list --- README_CN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README_CN.md b/README_CN.md index 4dc87ef..54fda9b 100644 --- a/README_CN.md +++ b/README_CN.md @@ -58,7 +58,7 @@ SuidRich新增支持List参数的批量插入方法. public String selectWithFun(T entity, FunctionType functionType, String fieldForFun, Condition condition); public int count(T entity); public int count(T entity, Condition condition); - public boolean exist(T entity); //判断记录是否存在 + public boolean exist(T entity); //判断记录是否存在 SuidRich调整selectById方法且String类型参数的id智能识别Javabean的id类型. Suid新增insertAndReturnId方法. 加强聚合函数cont,sum,avg,min,max功能,Condition增加方法: -- Gitee From 0867da885ff20e8a774b13488825040e210e4086 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Fri, 30 Apr 2021 10:18:27 +0800 Subject: [PATCH 103/124] update V1.9 function list --- Changed_Log.md | 13 ++++++++++--- Changed_Log_CN.md | 17 ++++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Changed_Log.md b/Changed_Log.md index bafab31..48e30c3 100644 --- a/Changed_Log.md +++ b/Changed_Log.md @@ -196,13 +196,16 @@ enhance SuidRich function, SuidRich add method: public String selectWithFun(T entity, FunctionType functionType, String fieldForFun, Condition condition); public int count(T entity); public int count(T entity, Condition condition); + public boolean exist(T entity); //check the record whether exist in table SuidRich adjust methods selectById for unique entity and intelligently judge the Javabean id type of string id parameter. +Suid add method insertAndReturnId. enhance aggregate function cont,sum,avg,min,max,Condition add method: public Condition selectFun(FunctionType functionType,String fieldForFun); public Condition selectFun(FunctionType functionType,String fieldForFun,String alias); Condition add method:opWithField,setWithField support like :field1=field2 -no Javabean, use map to set the entity information that needs to be transformed and operate the database(select/delete record). -support read excel(*.xls,*.xlsx), converting data into List and importing them into database(bee-ext). +Condition add method:selectDistinctField,support distinct as select distinct(userid) from table_name +MapSuid,no need Javabean, use map to set the entity information that needs to be transformed and operate the database(select/insert/delete record). +support read Excel(*.xls,*.xlsx), converting data into List and importing them into database(bee-ext). more table join select support more join condition. same Connection for some ORM operation. support different type muli-Ds at same time. @@ -212,8 +215,12 @@ support define start and end token when generate file by template. enhance DB conn management. enhance code quality. enhance chain coding:Select,Update. -update batchSize(bee.osql.insert.batchSize) in bee.properties. +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). \ No newline at end of file diff --git a/Changed_Log_CN.md b/Changed_Log_CN.md index ad411f4..bd2ce5c 100644 --- a/Changed_Log_CN.md +++ b/Changed_Log_CN.md @@ -183,12 +183,15 @@ SuidRich新增支持List参数的批量插入方法. public String selectWithFun(T entity, FunctionType functionType, String fieldForFun, Condition condition); public int count(T entity); public int count(T entity, Condition condition); + public boolean exist(T entity); //判断记录是否存在 SuidRich调整selectById方法且String类型参数的id智能识别Javabean的id类型. +Suid新增insertAndReturnId方法. 加强聚合函数cont,sum,avg,min,max功能,Condition增加方法: public Condition selectFun(FunctionType functionType,String fieldForFun); public Condition selectFun(FunctionType functionType,String fieldForFun,String alias); Condition 添加方法:opWithField,setWithField 支持像:field1=field2的表达式 -无Javabean,用map承载需要转换的实体信息,操作数据库(查询,删除数据). +Condition 添加方法:selectDistinctField,支持distinct像 select distinct(userid) from table_name +MapSuid,无需Javabean,用map承载需要转换的实体信息,操作数据库(查询,插入,删除数据). 支持读取Excel(*.xls,*.xlsx),并将数据转成List,且导入到数据库(bee-ext). 多表关联查询支持多个关联条件. 多个ORM操作使用同一个Connection. @@ -199,10 +202,14 @@ Condition 添加方法:opWithField,setWithField 支持像:field1=field2的表达 完善DB连接管理. 加强代码质量. 增强链式编程:Select,Update. -更新bee.properties文件中batchSize(bee.osql.insert.batchSize). +调整bee.properties,HoneyConfig配置信息. +整合Spring boot,提供bee-spring-boot-starter. +支持利用Javabean生成表. 修复多表分页查询时,同名字段在部分数据库会混淆的缺陷(oracle). -修改缺陷:update默认主键为id时,无id字段或id为null时,异常处理. -修改缺陷:cache bug. -强烈建议:使用视图时,声明视图不放缓存(因会产生脏数据). +修复缺陷:update默认主键为id时,无id字段或id为null时,异常处理. +修复缺陷:cache bug. +修复缺陷:有关GenId的 getRangeId(int sizeOfIds)方法. +修复缺陷:jdk 11下,LoggerFactory在配置log4j2时,报错. +强烈建议:使用视图时,声明视图不放缓存(因会产生脏数据). \ No newline at end of file -- Gitee From c8827691f027803e12172951ad961700e6749c04 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sat, 1 May 2021 01:03:24 +0800 Subject: [PATCH 104/124] update SuidRich API comment --- src/main/java/org/teasoft/bee/osql/SuidRich.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/teasoft/bee/osql/SuidRich.java b/src/main/java/org/teasoft/bee/osql/SuidRich.java index 1fb01a3..00d681f 100644 --- a/src/main/java/org/teasoft/bee/osql/SuidRich.java +++ b/src/main/java/org/teasoft/bee/osql/SuidRich.java @@ -32,11 +32,13 @@ import java.util.List; *
滤NULL和空字符串,可通过IncludeType显示设置). * *
updateBy方法中,String whereFields(若有),可以指明用于SQL中WHERE的字段.当指定了whereFields, 没在whereFields的字段,将默认 - *
转换为SQL UPDATE语句的SET部分(默认过滤NULL和空字符串,可通过IncludeType显示设置);另外,需要注意的是,id字段是不允许更改的. + *
转换为SQL UPDATE语句的SET部分(默认过滤NULL和空字符串,可通过IncludeType显示设置). *
同一个实体的某个属性的值,若用于WHERE部分了,再用于UPDATE SET部分就没有意义(因为此时它们的值是一样的),但可以用Condition的 *
set(String fieldName, Number num)等方法设置;Condition的方法set,setMultiply,setAdd,setWithField,是在处理WHERE字段前 *
已完成处理的,所以不受指定的WHERE条件字段的影响. * + *
update和updateBy方法的Condition设置的字段都会被解析,不受IncludeType的限制,也不受updateFields参数和whereFields参数的影响. + * * @author Kingstar * Create on 2013-6-30 22:06:18 * @since 1.0 -- Gitee From 1fb01b028f5037ba7a20248155a4e3231dabb9c9 Mon Sep 17 00:00:00 2001 From: aiteasoft Date: Sat, 1 May 2021 01:11:15 +0800 Subject: [PATCH 105/124] update src/main/java/org/teasoft/bee/osql/SuidRich.java. --- src/main/java/org/teasoft/bee/osql/SuidRich.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/org/teasoft/bee/osql/SuidRich.java b/src/main/java/org/teasoft/bee/osql/SuidRich.java index 00d681f..a983c5c 100644 --- a/src/main/java/org/teasoft/bee/osql/SuidRich.java +++ b/src/main/java/org/teasoft/bee/osql/SuidRich.java @@ -546,5 +546,11 @@ 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). + * @return true,if have the record;or return false. + * @since 1.9 + */ public boolean exist(T entity); } -- Gitee From 9feb8af49ba15a2f05a85bb892f5d18f1520b108 Mon Sep 17 00:00:00 2001 From: aiteasoft Date: Sat, 1 May 2021 01:12:18 +0800 Subject: [PATCH 106/124] update src/main/java/org/teasoft/bee/osql/SuidRich.java. --- src/main/java/org/teasoft/bee/osql/SuidRich.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/org/teasoft/bee/osql/SuidRich.java b/src/main/java/org/teasoft/bee/osql/SuidRich.java index a983c5c..1a99eba 100644 --- a/src/main/java/org/teasoft/bee/osql/SuidRich.java +++ b/src/main/java/org/teasoft/bee/osql/SuidRich.java @@ -256,8 +256,6 @@ public interface SuidRich extends Suid { */ public int insert(T[] entity,int batchSize,String excludeFields); - - /** * 批量插入数据.Insert records by batch type. * @param entityList 与表对应的实体对象链表,且不能为空. table's entity list(do not allow null). -- Gitee From b1f406784030bea3b03a8da2cf28f060509a0b7a Mon Sep 17 00:00:00 2001 From: aiteasoft Date: Sat, 1 May 2021 01:19:21 +0800 Subject: [PATCH 107/124] update src/main/java/org/teasoft/bee/osql/MapSuid.java. --- src/main/java/org/teasoft/bee/osql/MapSuid.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/teasoft/bee/osql/MapSuid.java b/src/main/java/org/teasoft/bee/osql/MapSuid.java index 9286bf9..8660bdd 100644 --- a/src/main/java/org/teasoft/bee/osql/MapSuid.java +++ b/src/main/java/org/teasoft/bee/osql/MapSuid.java @@ -70,11 +70,15 @@ public interface MapSuid { public int delete(MapSql mapSql); /** - * 插入并返回记录的id值. + * 插入并返回记录的id值.Insert and return the id value of the record. * id值可由Bee自动生成分布式id. - * 注意:若id由DB生成,需考虑DB是否支持,且对应JDBC驱动要支持返回id. - * @param mapSql + *
注意:若id由DB生成,需考虑DB是否支持,且对应JDBC驱动要支持返回id. + *
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值;若失败则返回-1. + *
If successful, return the id value of the inserted record; If fails, return -1. */ public long insert(MapSql mapSql); -- Gitee From 1dad2ab20e70090df476e60aa12d51c52207edf4 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sat, 1 May 2021 10:08:07 +0800 Subject: [PATCH 108/124] update for V1.9.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 856653b..2eae1f0 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.teasoft bee - 1.9-SNAPSHOT + 1.9.5 jar -- Gitee From 8fe4b3871880f1cc68cb4345b91987851337b696 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sun, 2 May 2021 02:24:35 +0800 Subject: [PATCH 109/124] enhance the code --- .../java/org/teasoft/bee/logging/Path.java | 2 + .../java/org/teasoft/bee/osql/BeeSql.java | 3 +- .../org/teasoft/bee/osql/DatabaseConst.java | 50 +++++++++---------- .../osql/ObjSQLIllegalSQLStringException.java | 2 +- .../java/org/teasoft/bee/osql/ObjToSQL.java | 1 - .../org/teasoft/bee/osql/ObjToSQLRich.java | 9 ++-- .../org/teasoft/bee/osql/PreparedSql.java | 6 +-- 7 files changed, 34 insertions(+), 39 deletions(-) diff --git a/src/main/java/org/teasoft/bee/logging/Path.java b/src/main/java/org/teasoft/bee/logging/Path.java index add43dd..10240b9 100644 --- a/src/main/java/org/teasoft/bee/logging/Path.java +++ b/src/main/java/org/teasoft/bee/logging/Path.java @@ -26,6 +26,8 @@ public class Path { private static String fullPath=""; + private Path() {} + public static String getFullPath(){ return fullPath; } diff --git a/src/main/java/org/teasoft/bee/osql/BeeSql.java b/src/main/java/org/teasoft/bee/osql/BeeSql.java index ea04579..3a6a146 100644 --- a/src/main/java/org/teasoft/bee/osql/BeeSql.java +++ b/src/main/java/org/teasoft/bee/osql/BeeSql.java @@ -68,9 +68,8 @@ public interface BeeSql { * 用函数查询结果.Select result with function. SQL function: max,min,avg,sum,count. * @param sql SQL select statement * @return 函数统计的值.如果统计的结果集为空,除了count返回0,其它都返回空字符. - * @throws ObjSQLException */ - public String selectFun(String sql) throws ObjSQLException; + public String selectFun(String sql) ; /** diff --git a/src/main/java/org/teasoft/bee/osql/DatabaseConst.java b/src/main/java/org/teasoft/bee/osql/DatabaseConst.java index 1af6cea..13c9819 100644 --- a/src/main/java/org/teasoft/bee/osql/DatabaseConst.java +++ b/src/main/java/org/teasoft/bee/osql/DatabaseConst.java @@ -5,35 +5,35 @@ package org.teasoft.bee.osql; * @author Kingstar * @since 1.0 */ -public interface DatabaseConst { +public final class DatabaseConst { - String MYSQL = "MySQL"; - String MariaDB = "MariaDB"; - String ORACLE = "Oracle"; - String SQLSERVER = "Microsoft SQL Server"; + public static final String MYSQL = "MySQL"; + public static final String MariaDB = "MariaDB"; + public static final String ORACLE = "Oracle"; + public static final String SQLSERVER = "Microsoft SQL Server"; - String H2 = "H2"; - String SQLite = "SQLite"; - String PostgreSQL = "PostgreSQL"; + public static final String H2 = "H2"; + public static final String SQLite = "SQLite"; + public static final String PostgreSQL = "PostgreSQL"; - String Cubrid = "Cubrid"; - String DB2400 = "DB2 UDB for AS/400"; - String DB2 = "DB2"; //todo - String Derby = "Apache Derby"; - String Firebird = "Firebird"; - String FrontBase = "FrontBase"; + public static final String Cubrid = "Cubrid"; + public static final String DB2400 = "DB2 UDB for AS/400"; + public static final String DB2 = "DB2"; //todo + public static final String Derby = "Apache Derby"; + public static final String Firebird = "Firebird"; + public static final String FrontBase = "FrontBase"; - String HSQL = "HSQL Database Engine"; - String Informix = "Informix Dynamic Server"; - String Ingres = "Ingres"; - String JDataStore = "JDataStore"; - String Mckoi = "Mckoi"; - String MimerSQL = "MimerSQL"; - String Pointbase = "Pointbase"; + public static final String HSQL = "HSQL Database Engine"; + public static final String Informix = "Informix Dynamic Server"; + public static final String Ingres = "Ingres"; + public static final String JDataStore = "JDataStore"; + public static final String Mckoi = "Mckoi"; + public static final String MimerSQL = "MimerSQL"; + public static final String Pointbase = "Pointbase"; - String SAPDB = "SAPDB"; - String Sybase = "Sybase SQL Server"; - String Teradata = "Teradata"; - String TimesTen = "TimesTen"; + public static final String SAPDB = "SAPDB"; + public static final String Sybase = "Sybase SQL Server"; + public static final String Teradata = "Teradata"; + public static final String TimesTen = "TimesTen"; } diff --git a/src/main/java/org/teasoft/bee/osql/ObjSQLIllegalSQLStringException.java b/src/main/java/org/teasoft/bee/osql/ObjSQLIllegalSQLStringException.java index 67b03ef..8d746f1 100644 --- a/src/main/java/org/teasoft/bee/osql/ObjSQLIllegalSQLStringException.java +++ b/src/main/java/org/teasoft/bee/osql/ObjSQLIllegalSQLStringException.java @@ -5,7 +5,7 @@ package org.teasoft.bee.osql; * @author Kingstar * @since 1.0 */ -public class ObjSQLIllegalSQLStringException extends ObjSQLException { +public class ObjSQLIllegalSQLStringException extends BeeException { static final long serialVersionUID = -875516993124211122L; public ObjSQLIllegalSQLStringException() { super(); diff --git a/src/main/java/org/teasoft/bee/osql/ObjToSQL.java b/src/main/java/org/teasoft/bee/osql/ObjToSQL.java index 908ba08..7121d0a 100644 --- a/src/main/java/org/teasoft/bee/osql/ObjToSQL.java +++ b/src/main/java/org/teasoft/bee/osql/ObjToSQL.java @@ -29,7 +29,6 @@ package org.teasoft.bee.osql; public interface ObjToSQL { public String toSelectSQL(T entity) ; -// public String toUpdateSQL(T entity) throws ObjSQLException; public String toUpdateSQL(T entity) ; public String toInsertSQL(T entity) ; public String toDeleteSQL(T entity) ; diff --git a/src/main/java/org/teasoft/bee/osql/ObjToSQLRich.java b/src/main/java/org/teasoft/bee/osql/ObjToSQLRich.java index 19b8cf9..6adfc0f 100644 --- a/src/main/java/org/teasoft/bee/osql/ObjToSQLRich.java +++ b/src/main/java/org/teasoft/bee/osql/ObjToSQLRich.java @@ -27,18 +27,16 @@ 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) throws ObjSQLException; + public String toSelectSQL(T entity,String fields); public String toSelectSQL(T entity,String selectFields,int start,int size); -// public String toUpdateSQL(T entity,String updateFieldList) throws ObjSQLException; -// public String toUpdateSQL(T entity,String updateFieldList,IncludeType includeType) throws ObjSQLException; 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 toSelectOrderBySQL(T entity, String orderFields) throws ObjSQLException; - public String toSelectOrderBySQL(T entity, String orderFields,OrderType[] orderTypes) throws ObjSQLException; + public String toSelectOrderBySQL(T entity, String orderFields); + public String toSelectOrderBySQL(T entity, String orderFields,OrderType[] orderTypes); public String toSelectSQL(T entity, IncludeType includeType); public String toDeleteSQL(T entity, IncludeType includeType); @@ -46,7 +44,6 @@ public interface ObjToSQLRich extends ObjToSQL { public String toUpdateSQL(T entity, IncludeType includeType); public String[] toInsertSQL(T[] entity); -// public String[] toInsertSQL(T[] entity,int batchSize); public String[] toInsertSQL(T[] entity,String excludeFields); public String[] toInsertSQL(T[] entity,int batchSize,String excludeFields); diff --git a/src/main/java/org/teasoft/bee/osql/PreparedSql.java b/src/main/java/org/teasoft/bee/osql/PreparedSql.java index 126e454..8da849e 100644 --- a/src/main/java/org/teasoft/bee/osql/PreparedSql.java +++ b/src/main/java/org/teasoft/bee/osql/PreparedSql.java @@ -152,9 +152,8 @@ public interface PreparedSql { * @param sql SQL select statement * @param preValues 按下标顺序给sql的占位符设值的Object数组. * @return 返回函数统计的值.如果统计的结果集为空,除了count返回0,其它都返回空字符. - * @throws ObjSQLException */ - public String selectFun(String sql,Object preValues[]) throws ObjSQLException; + public String selectFun(String sql,Object preValues[]); /** * 用函数查询结果.Select result with function. SQL function: max,min,avg,sum,count.

@@ -162,9 +161,8 @@ public interface PreparedSql { * @param sqlStr SQL select statement * @param map map结构的参数,通过map的key与sqlStr中变量名对应. * @return 返回函数统计的值.如果统计的结果集为空,除了count返回0,其它都返回空字符. - * @throws ObjSQLException */ - public String selectFun(String sqlStr,Map map) throws ObjSQLException; + public String selectFun(String sqlStr, Map map); /** * 查询并将每一行结果转成String数组.Select and transform every record to string array.

-- Gitee From 310ac33e51e0ff8ce6054640da36b756e7b7cbe9 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sun, 2 May 2021 15:52:56 +0800 Subject: [PATCH 110/124] update the Bee version to 1.9.5 --- README_CN.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README_CN.md b/README_CN.md index 54fda9b..7df20fb 100644 --- a/README_CN.md +++ b/README_CN.md @@ -229,18 +229,18 @@ OrdersService.java org.teasoft bee - 1.8.99 + 1.9.5 org.teasoft honey - 1.8.99 + 1.9.5 org.teasoft bee-ext - 1.8.99 + 1.9.5 ``` -- Gitee From 869690992b08f850130515c71dffa0b84f72407b Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sun, 2 May 2021 15:53:03 +0800 Subject: [PATCH 111/124] update the Bee version to 1.9.5 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4750827..b5fc64c 100644 --- a/README.md +++ b/README.md @@ -271,18 +271,18 @@ Quick Start: org.teasoft bee - 1.8.99 + 1.9.5 org.teasoft honey - 1.8.99 + 1.9.5 org.teasoft bee-ext - 1.8.99 + 1.9.5 ``` -- Gitee From 7f1642ca4026ebad88bbfd528e6466551aa1a759 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sun, 2 May 2021 16:02:53 +0800 Subject: [PATCH 112/124] add Bee+Spring-boot Demo --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b5fc64c..8645986 100644 --- a/README.md +++ b/README.md @@ -371,6 +371,8 @@ public class SuidExamEN { #### [More example/test case](../../../bee-exam/) +#### [Bee+Spring-boot Demo](../../../bee-starter-demo/) + Rapid application development: ========= **Let Java more quicker programming than php and Rails.** -- Gitee From cc4090858646f16009f451f139b101a04ad058cf Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sun, 2 May 2021 16:03:16 +0800 Subject: [PATCH 113/124] add Bee+Spring-boot Demo --- README_CN.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README_CN.md b/README_CN.md index 7df20fb..b409a65 100644 --- a/README_CN.md +++ b/README_CN.md @@ -333,6 +333,8 @@ public class SuidExam { #### [更多例子/测试用例](../../../bee-exam/) +#### [Bee+Spring-boot Demo](../../../bee-starter-demo/) + 综合应用: ========= **Java快速编程, 让Java的开发速度超过php和Rails。** -- Gitee From 6c1a9565a4f41e621675f73f4cc4e5a4285e673a Mon Sep 17 00:00:00 2001 From: Kingstar Date: Sun, 2 May 2021 16:41:49 +0800 Subject: [PATCH 114/124] V1.9.5 jar,just 315k,include(Bee,Honey,bee-ext,bee-spring-boot) --- README.md | 1 + README_CN.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8645986..373452b 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ 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.0** Single entity(table) Suid (select,update,insert,delete) object-oriented operation. diff --git a/README_CN.md b/README_CN.md index b409a65..10d1fb8 100644 --- a/README_CN.md +++ b/README_CN.md @@ -43,7 +43,7 @@ jdk1.7+ * 16.**支持同库分表,动态表名映射**。 * 17.可以不用表对应的Javabean也能操作DB。 * 18.**无**第三方插件依赖;可零配置使用。 -* 19.**性能好:接近JDBC的速度;文件小:Bee V1.8 jar 仅217k**。 +* 19.**性能好:接近JDBC的速度;文件小:Bee V1.8 jar 仅217k**, **V1.9.5 jar,仅315k**。 辅助功能: * 20.支持自动生成表对应的Javabean,根据Javabean创建表,Javaweb**后端代码**根据**模板自动生成**;能打印非占位符的**可执行sql**,方便调试。 * 21.支持**读取Excel**,从Excel导入数据到DB,操作简单。 -- Gitee From b179ce0ea72f2716a21c1b30daa173ded10cf16f Mon Sep 17 00:00:00 2001 From: Kingstar Date: Wed, 5 May 2021 15:43:49 +0800 Subject: [PATCH 115/124] =?UTF-8?q?why=20Bee=20do=20not=20have=20those=20m?= =?UTF-8?q?ethod=EF=BC=9AfindAll(),deleteAll(),save(),mapper,=20dao?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FAQ_CN.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/FAQ_CN.md b/FAQ_CN.md index eee7efd..7deabcd 100644 --- a/FAQ_CN.md +++ b/FAQ_CN.md @@ -264,6 +264,44 @@ More SQL Function, more Group by } ``` +22. + +Q: Bee为什么没有findAll(),deleteAll()方法? +A: 在一个系统里,几乎是不会有删除整个表的应用场景的。即使写demo样例也很少。所在Bee还特意加了一个检测开关, + 以防止误删整个表的数据。 要是软删除(只标记一个字段状态表示不用该数据了),那直接用update就好了。 + findAll()应用的场景也很有限,除了配置表,只存储少量记录,会查询所有数据;像用户表,订单表等是不可能查询所有数据的, + 一般都是要分页(另外,Bee的分页功能比其它工具的都好用,性能也高)。在Bee,查询所有数据,可以用: + suid.select(new ConstValue());//查询所有常量,假设表名对应的实体名为:ConstValue + + +23. + +Q: Bee为什么没有save方法? +A: 别的ORM框架,将insert与update合为一个save方法,每次操作前都要查询一次数据,看数据库是否存在该记录, + 以确定是要用insert还是update. 更新操作时,entity要设置id值,以便让查询确定该实体是否存在。 + 当使用mysql数据库且JPA主键策略为@GeneratedValue(strategy = GenerationType.IDENTITY),全局更新未带version数据时, + 更新操作会变为保存操作。 + 但在很多业务场景,insert与update是明确可以区分开的,特别是在互联网应用。 + 要是用save反而会降低系统的性能。 + 如果确实有需要,可自己封装一个,参考: + + ```java + public int save(Orders orders) { + Orders one = suidRich.selectById(orders, orders.getId()); + if (one != null) + return suidRich.update(orders); + else + return suidRich.insert(orders); + } + ``` + + +24. + +Q: Bee为什么不需要写mapper,dao? +A: 这是Bee的一大优势,Bee的编码复杂度是O(1). Bee概念简单,易于使用,编码量少。 + Bee通过约定优于配置原则,通过封装,已经简化了开发. + **其它相关资源:** -- Gitee From 22f75a661011bd3041f8effdb05d2978b9f7a50b Mon Sep 17 00:00:00 2001 From: Kingstar Date: Wed, 5 May 2021 17:18:45 +0800 Subject: [PATCH 116/124] add V1.9 test log --- src/test/java/org/teasoft/bee/BeeExam.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/java/org/teasoft/bee/BeeExam.java b/src/test/java/org/teasoft/bee/BeeExam.java index 61d3e87..8cce73e 100644 --- a/src/test/java/org/teasoft/bee/BeeExam.java +++ b/src/test/java/org/teasoft/bee/BeeExam.java @@ -165,6 +165,22 @@ public class BeeExam { // bee-exam(v1.9)2021-04-03 21.56.10.191-normal(PostgreSQL).txt // bee-exam(v1.9)2021-04-03 21.56.22.701-normal(Microsoft SQL Server).txt // bee-exam(v1.9)2021-04-03 21.56.30.119-cache(MySQL).txt + +// bee-exam(v1.9)2021-04-08 00.22.59.444-normal(MySQL).txt +// bee-exam(v1.9)2021-04-08 00.23.12.834-normal(Oracle).txt +// bee-exam(v1.9)2021-04-08 00.23.36.883-normal(SQLite).txt +// bee-exam(v1.9)2021-04-08 00.23.52.876-normal(H2).txt +// bee-exam(v1.9)2021-04-08 00.23.57.141-normal(PostgreSQL).txt +// bee-exam(v1.9)2021-04-08 00.24.08.533-normal(Microsoft SQL Server).txt +// bee-exam(v1.9)2021-04-08 00.24.15.820-cache(MySQL).txt +// +// bee-exam(v1.9)2021-05-02 02.53.30.778-normal(MySQL).txt +// bee-exam(v1.9)2021-05-02 02.53.47.666-normal(Oracle).txt +// bee-exam(v1.9)2021-05-02 02.54.08.829-normal(SQLite).txt +// bee-exam(v1.9)2021-05-02 02.54.26.717-normal(H2).txt +// bee-exam(v1.9)2021-05-02 02.54.34.977-normal(PostgreSQL).txt +// 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 } } -- Gitee From 2eb7795c67419d949c3edd5bc27d76a35f9576f7 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Wed, 5 May 2021 17:18:50 +0800 Subject: [PATCH 117/124] add V1.9 test log --- src/test/java/org/teasoft/bee/change-log.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/java/org/teasoft/bee/change-log.txt b/src/test/java/org/teasoft/bee/change-log.txt index a6d659d..894943b 100644 --- a/src/test/java/org/teasoft/bee/change-log.txt +++ b/src/test/java/org/teasoft/bee/change-log.txt @@ -106,3 +106,19 @@ bee-exam(v1.9)2021-04-03 21.56.05.780-normal(H2).txt bee-exam(v1.9)2021-04-03 21.56.10.191-normal(PostgreSQL).txt bee-exam(v1.9)2021-04-03 21.56.22.701-normal(Microsoft SQL Server).txt bee-exam(v1.9)2021-04-03 21.56.30.119-cache(MySQL).txt + +bee-exam(v1.9)2021-04-08 00.22.59.444-normal(MySQL).txt +bee-exam(v1.9)2021-04-08 00.23.12.834-normal(Oracle).txt +bee-exam(v1.9)2021-04-08 00.23.36.883-normal(SQLite).txt +bee-exam(v1.9)2021-04-08 00.23.52.876-normal(H2).txt +bee-exam(v1.9)2021-04-08 00.23.57.141-normal(PostgreSQL).txt +bee-exam(v1.9)2021-04-08 00.24.08.533-normal(Microsoft SQL Server).txt +bee-exam(v1.9)2021-04-08 00.24.15.820-cache(MySQL).txt + +bee-exam(v1.9)2021-05-02 02.53.30.778-normal(MySQL).txt +bee-exam(v1.9)2021-05-02 02.53.47.666-normal(Oracle).txt +bee-exam(v1.9)2021-05-02 02.54.08.829-normal(SQLite).txt +bee-exam(v1.9)2021-05-02 02.54.26.717-normal(H2).txt +bee-exam(v1.9)2021-05-02 02.54.34.977-normal(PostgreSQL).txt +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 -- Gitee From 01f762f897284ff873b55aa5c559e50a9afb7181 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Wed, 5 May 2021 18:02:16 +0800 Subject: [PATCH 118/124] =?UTF-8?q?why=20Bee=20have=20not=20those=20method?= =?UTF-8?q?s=EF=BC=9AfindAll(),deleteAll(),save(),=20mapper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FAQ_CN.md | 1 + 1 file changed, 1 insertion(+) diff --git a/FAQ_CN.md b/FAQ_CN.md index 7deabcd..ee9a993 100644 --- a/FAQ_CN.md +++ b/FAQ_CN.md @@ -279,6 +279,7 @@ A: 在一个系统里,几乎是不会有删除整个表的应用场景的。 Q: Bee为什么没有save方法? A: 别的ORM框架,将insert与update合为一个save方法,每次操作前都要查询一次数据,看数据库是否存在该记录, 以确定是要用insert还是update. 更新操作时,entity要设置id值,以便让查询确定该实体是否存在。 + 相当于更新操作,只能以id为where 条件,一次只能更新一条(有更新多条的需要时,这种做法效率不会高)。 当使用mysql数据库且JPA主键策略为@GeneratedValue(strategy = GenerationType.IDENTITY),全局更新未带version数据时, 更新操作会变为保存操作。 但在很多业务场景,insert与update是明确可以区分开的,特别是在互联网应用。 -- Gitee From 5bdc7586db6d35730915d72081eceb341dbb7f26 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Wed, 5 May 2021 20:39:00 +0800 Subject: [PATCH 119/124] =?UTF-8?q?why=20Bee=20have=20not=20those=20method?= =?UTF-8?q?s=EF=BC=9AfindAll(),deleteAll(),save(),=20mapper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FAQ_CN.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/FAQ_CN.md b/FAQ_CN.md index ee9a993..7e2b33c 100644 --- a/FAQ_CN.md +++ b/FAQ_CN.md @@ -288,6 +288,8 @@ A: 别的ORM框架,将insert与update合为一个save方法,每次操作前 ```java public int save(Orders orders) { + if(orders==null) return 0; + if(orders.getId()==null) return suidRich.insert(orders); Orders one = suidRich.selectById(orders, orders.getId()); if (one != null) return suidRich.update(orders); -- Gitee From 31b7a4d8d0b7b3f439ce566a5d7e2e32d3feb12c Mon Sep 17 00:00:00 2001 From: Kingstar Date: Wed, 5 May 2021 23:32:05 +0800 Subject: [PATCH 120/124] update for V1.9.5 --- FAQ_CN-before1.8.99.md | 317 +++++++++++++++++++++++++++++++++++++++++ FAQ_CN.md | 30 ++-- 2 files changed, 333 insertions(+), 14 deletions(-) create mode 100644 FAQ_CN-before1.8.99.md diff --git a/FAQ_CN-before1.8.99.md b/FAQ_CN-before1.8.99.md new file mode 100644 index 0000000..7e2b33c --- /dev/null +++ b/FAQ_CN-before1.8.99.md @@ -0,0 +1,317 @@ +常见问题收集: + +1. + +Q: Bee支持几种数据库? + +A: MySQL,MariaDB,Oracle,SQL Server,H2,SQLite,PostgreSQL等等都是支持的,只要该DB支持JDBC,Bee就可以轻松支持它! + +2. + +Q: 表与实体Javabean可以自动映射吗? + +A: Bee采用约定优于配置的方式,默认实现有三种方式, 且支持自定义映射规则扩展. +在bee.properties作相关配置即可切换默认实现方式. + +```properties +#since 1.7.2 +#default implement translate type. 1 : order_no<-->orderNo(DB<-->Java), 2: ORDER_NO<-->orderNo(DB<-->Java), 3: original +#if want to use other naming rule, you can define a new class implements NameTranslate +#default value is :1 +bee.osql.naming.translate.type=1 +``` + +3. + +Q: Bee支持读写分离,支持多数据源吗? + +A: V1.8支持读写分离一主多从, 仅分库等多数据源模式。 +分布式环境下生成连续单调递增(在一个workerid内),全局唯一数字id。 + +4. + + +Q: 在一个DB中,随着数据量不断增长,需要将老的数据移到历史表中. 如,订单表orders,将5月,6月数据移到 orders\_202005,orders\_202006,结构与表orders一样。 如何用同一Javabean,同时映射多个数据表? + +A: V1.8支持同库分表,动态表名映射.  + +参考: [https://gitee.com/automvc/bee/issues/I1P8YH](https://gitee.com/automvc/bee/issues/I1P8YH)  + +或: [https://github.com/automvc/bee/issues/18](https://github.com/automvc/bee/issues/18) + +5. + +Q: Bee有说明文档吗?有测试用例吗?这么好用的orm竟然没文档??!!! + +A: 请参考Bee源码网站wiki,或: JavaWeb开发的利器 系统文章,请关注微信公众号: 软件设计活跃区. 测试用例,请查看:[https://gitee.com/automvc/bee-exam](https://gitee.com/automvc/bee-exam) + +6. + + +Q: 请教下bee的多对多映射是类似mybatis那种可以全部查出来然后映射,还是hibernate那种多次查询? + +A: bee更接近原生SQL,可用原生语句分页,不需要全部查出来,也不需要查多次 wiki相关文档: (四): 分页、查询部分字段原来如此简单 (六): 多表查询(面向对象方式) + +7. + + +Q: Bee怎么具有AI特性? + +A: 通过从手工写sql语句直接用JDBC操作数据库,到简单的DB工具类, 再到像Hibernate的旧版本通过操作对象将操作DB封闭到Dao; 再到后来写dao都觉得累赘,通用操作只写个空接口。 ORM工具的发展,就是一步一提炼,简化操作的历史。 假如用AI学习,演变,那写空接口都会觉得是多余的, 每个数据库表不就是表名,以及包含一些列而矣吗??!!! 为什么不能用同样的方式去处理呢??!!! 而且dao层可以直接去掉放到ORM框架统一处理。 为了实现这些目标,就有了Bee框架。 原来编码复杂度是O(n)的,现在变成是O(1),无论多少个表,你都可以不用另外再写dao代码。 可以用时间复杂度和空间复杂度体会下编码复杂度这种变化。 + +8. + + +Q: 分布式ORM正在解决的问题之一: 能不能找到一种,既不依赖DB,也不依赖时间的ID生成算法呢? DB表自增ID真的不能用在分布式场景吗? + +A: 都是可以的.参考Bee的org.teasoft.bee.distribution.GenId接口的三种实现. + +9. + + +Q: 与传统ORM工具的比较? + +A: Hibernate的概念太复杂,学习成本高,更新会先查询再更新,n+1问题。Mybatis即使进行单表的Suid操作也需要人工写sql或生成sql文件,需要维护的sql太多。 更多比较,参考: [https://blog.csdn.net/abckingaa/article/details/84557336](https://blog.csdn.net/abckingaa/article/details/84557336) + +10. + + +Q: Bee如何提高Java web软件开发效率? + +A: 除了可以不需要写dao代码外(编码复杂度为O(1)),还提供了表对应的实体Javabean自动生成工具, 根据模板自动生成Java web前后端代码;人性化的SQL日志,可输出直接运行的sql语句(有占位符的SQL不能直接运行,不方便调试). + +11. + + +Q: Bee支持缓存吗? 如何设置缓存? + +A: 支持。还可以像调优JVM一样,对一级缓存进行调优。有暂时缓存,也有永久缓存,还有可以同步更新的永久缓存。 + +```properties +#cache=======================start +#缓存类型 +#bee.osql.cache.type=FIFO +#缓存集数据量数目 +bee.osql.cache.map.size=10 +#resultset超过一定的值将不会放缓存 +bee.osql.cache.work.resultSet.size=300 +#缓存保存时间(毫秒 ms) +bee.osql.cache.timeout=10000 +#检测到超时,超过这个使用比例则顺便起线程清除缓存 +bee.osql.cache.startDeleteCache.rate=0.6 +#缓存容量使用率;添加缓存,检测达到该使用率则清除一定比例缓存 +bee.osql.cache.fullUsed.rate=0.8 +#添加缓存,检测到缓存容量快满时,删除缓存数的比例 +bee.osql.cache.fullClearCache.rate=0.2 + +#仅分库时(bee.dosql.multi-DS.type=2),可用格式: dsName.tableName +#use table name, not entity name +#不缓存表的列表, 表名不区分大小写 +#bee.osql.cache.never=user +#永久缓存表的列表, 表名不区分大小写 +#bee.osql.cache.forever=constant +#永久缓存,但有更改时也会清除缓存,以便同步新的值到缓存. 表名不区分大小写 +#bee.osql.cache.forever.modifySyn=para + +# since v1.7.2. default value is: false (use cache) +#bee.osql.cache.nocache=true + +#cache=======================end + +``` + +12. + + +Q: Bee设计原理? + +A: 参考wiki或公众号相关文章: (十一):如何设计ORM架构及Bee源码分析 (十二):为什么需要一个新的ORM框架 + +13.Q: Bee查询自己怎么写筛选条件呢?像筛选状态大于2的 + +A: 写法类似: Condition condition=new ConditionImpl(); condition .op("status", Op.gt, 2) // 会转化到SQL中的where status>2 详情参考wiki: (五): 复杂查询(面向对象方式) (十三):update高级用法说明 + **更新的字段是在原来的基础上变化** +如某类商品提价2元,可以有如下写法。 +set price=price+2 + **这样写的好处,可以不需要查询出原来的价格,减少IO开销。** +Bee的面向对象写法: +condition.setAdd("price", 2); +suidRich.update(entity,condition); + +若字段p每次增加的值由字段step配置,则写为: +condition.setAdd("p", "step"); +会转化为: set p=p+step + +14.Q: Bee与Honey是什么关系? + +A: ORM Bee框架是采用接口与实现分离的设计方式.Bee是接口,而Honey则是Bee的实现. + +15. + +Q: Bee非常易用,编写代码少,但使用是一方面, 它的性能如何? + +A: 性能绝对是过得去的.README给出了详细的表格比较数据.  详细比较还开启了一个项目,欢迎PK。 +https://gitee.com/automvc/orm-compare + +16. + +Q: Bee适合手机开发领域吗? + +A: Bee文件小。bee V1.8 jar files 仅217k. 而且性能也接近JDBC的性能.还专门对H2,SQLite作了优化. + +17. + + +Q: 如何自动填日期字段? + +A: Bee默认不解析是null或空的字段; +当Javabean的日期是null时,Bee不会解析. 像mysql可以在DB端自动触发填充日期值。 + +18. + +Q: Bee对Excel导入有什么支持? 有简化操作吗? + +A: 轻松用ORM Bee实现将Excel的数据转成List,并导入到数据库。 +读取最简单的就一行代码: List list = ExcelReader.readExcel("D:\\test-dataType.xlsx"); +参考bee-exam项目里: +ExcelReaderTest.java +ImportExcelTest.java +八行代码搞定将excel数据导入到DB +https://blog.csdn.net/abckingaa/article/details/113603130 +或: +https://my.oschina.net/u/4111850/blog/4944468 + +19. + +Q: 没有与表对应的实体Javabean,如何操作数据? +A: 用map进行转换实体信息,查询/删除数据库中的数据. +参考bee-exam项目里: +MapSuidExam +```java + MapSuid mapSuid = BeeFactory.getHoneyFactory().getMapSuid(); + MapSql mapSql = BeeFactory.getHoneyFactory().getMapSql(); + + mapSql.put(MapSqlKey.Table, "test_user"); +// mapSql.put(MapSqlKey.Table, "testUser"); + mapSql.put(MapSqlKey.SelectColumns, "name,password"); + mapSql.put(MapSqlKey.OrderBy, "name"); + + mapSql.put(MapSqlSetting.IsNamingTransfer, true); +// mapSql.put(MapSqlSetting.IsIncludeEmptyString, true); + mapSql.put(MapSqlSetting.IsIncludeNull, true); + + mapSql.put("name", "Bee"); + mapSql.put("email", ""); //emptyString + mapSql.put("lastName", null); +// mapSql.put("last_name", null); + + String json = mapSuid.selectJson(mapSql); + Logger.info(json); +// mapSuid.selectJson(mapSql); //test cache + + mapSuid.select(mapSql); + mapSuid.select(mapSql); + + Map map = mapSuid.selectOne(mapSql); + if (ObjectUtils.isNotEmpty(map)) { + Logger.info(map.get("name").toString()); + Logger.info(map.get("password").toString()); + } + mapSuid.selectOne(mapSql); +``` + +20. + +Q:表对应的实体Javabean有些字段不想解析,如何实现? +A: +Ignore注解,忽略Javabean字段,不进行转换. +但这种应尽量少用. 纯的Javabean,当DB有变动时,很容易就可以更改了,自动生成纯Javabean更方便,安全. +Bee默认是不处理为null或空字符的字段的,因此,操作DB前将其置空即可. + +21. +How to use ORM Bee develop when the sql like: select examno, subject,max(score) ,avg(score) ,min(score) from scores? +Detail see wiki: +More SQL Function, more Group by + +```java + Condition condition=new ConditionImpl(); + + condition + .selectField("classno,term,examno,subject") + .selectFun(FunctionType.MAX, "score","maxScore") + .selectFun(FunctionType.AVG, "score","avgScore") + .selectFun(FunctionType.MIN, "score","minScore"); + + condition.op("status", Op.nq, "FIN"); + + condition + .groupBy("term,examno,subjectno,subject") + .orderBy("classno,term,examno,subjectno") + ; + + Scores scores=new Scores(); + String r=suidRich.selectJson(scores, condition); // json result + System.out.println(r); + + List listString=suidRich.selectString(scores, condition); // string array result + String str[]; + for (int i = 0; i < listString.size(); i++) { + str=listString.get(i); + for (int j = 0; j < str.length; j++) { + System.out.print(str[j]+" "); + } + System.out.println(); + } +``` + +22. + +Q: Bee为什么没有findAll(),deleteAll()方法? +A: 在一个系统里,几乎是不会有删除整个表的应用场景的。即使写demo样例也很少。所在Bee还特意加了一个检测开关, + 以防止误删整个表的数据。 要是软删除(只标记一个字段状态表示不用该数据了),那直接用update就好了。 + findAll()应用的场景也很有限,除了配置表,只存储少量记录,会查询所有数据;像用户表,订单表等是不可能查询所有数据的, + 一般都是要分页(另外,Bee的分页功能比其它工具的都好用,性能也高)。在Bee,查询所有数据,可以用: + suid.select(new ConstValue());//查询所有常量,假设表名对应的实体名为:ConstValue + + +23. + +Q: Bee为什么没有save方法? +A: 别的ORM框架,将insert与update合为一个save方法,每次操作前都要查询一次数据,看数据库是否存在该记录, + 以确定是要用insert还是update. 更新操作时,entity要设置id值,以便让查询确定该实体是否存在。 + 相当于更新操作,只能以id为where 条件,一次只能更新一条(有更新多条的需要时,这种做法效率不会高)。 + 当使用mysql数据库且JPA主键策略为@GeneratedValue(strategy = GenerationType.IDENTITY),全局更新未带version数据时, + 更新操作会变为保存操作。 + 但在很多业务场景,insert与update是明确可以区分开的,特别是在互联网应用。 + 要是用save反而会降低系统的性能。 + 如果确实有需要,可自己封装一个,参考: + + ```java + public int save(Orders orders) { + if(orders==null) return 0; + if(orders.getId()==null) return suidRich.insert(orders); + Orders one = suidRich.selectById(orders, orders.getId()); + if (one != null) + return suidRich.update(orders); + else + return suidRich.insert(orders); + } + ``` + + +24. + +Q: Bee为什么不需要写mapper,dao? +A: 这是Bee的一大优势,Bee的编码复杂度是O(1). Bee概念简单,易于使用,编码量少。 + Bee通过约定优于配置原则,通过封装,已经简化了开发. + + +**其它相关资源:** + +gitee issue: [https://gitee.com/automvc/bee/issues?assignee\_id=&author\_id=&branch=&issue\_search=&label\_name=&milestone\_id=&program\_id=&scope=&sort=&state=closed](https://gitee.com/automvc/bee/issues?assignee_id=&author_id=&branch=&issue_search=&label_name=&milestone_id=&program_id=&scope=&sort=&state=closed)  + +gitee wiki: [https://gitee.com/automvc/bee/wikis](https://gitee.com/automvc/bee/wikis) + +github issue: [https://github.com/automvc/bee/issues?q=is%3Aissue+is%3Aclosed](https://github.com/automvc/bee/issues?q=is%3Aissue+is%3Aclosed)  + +github wiki: [https://github.com/automvc/bee/wiki](https://github.com/automvc/bee/wiki) \ No newline at end of file diff --git a/FAQ_CN.md b/FAQ_CN.md index 7e2b33c..f850b3b 100644 --- a/FAQ_CN.md +++ b/FAQ_CN.md @@ -18,7 +18,7 @@ A: Bee采用约定优于配置的方式,默认实现有三种方式, 且支持 #default implement translate type. 1 : order_no<-->orderNo(DB<-->Java), 2: ORDER_NO<-->orderNo(DB<-->Java), 3: original #if want to use other naming rule, you can define a new class implements NameTranslate #default value is :1 -bee.osql.naming.translate.type=1 +bee.osql.naming.translateType=1 ``` 3. @@ -92,30 +92,32 @@ A: 支持。还可以像调优JVM一样,对一级缓存进行调优。有暂 #缓存类型 #bee.osql.cache.type=FIFO #缓存集数据量数目 -bee.osql.cache.map.size=10 +bee.osql.cache.mapSize=10 #resultset超过一定的值将不会放缓存 -bee.osql.cache.work.resultSet.size=300 +bee.osql.cache.workResultSetSize=300 #缓存保存时间(毫秒 ms) -bee.osql.cache.timeout=10000 +bee.osql.cache.timeout=3000 #检测到超时,超过这个使用比例则顺便起线程清除缓存 -bee.osql.cache.startDeleteCache.rate=0.6 +bee.osql.cache.startDeleteRate=0.6 #缓存容量使用率;添加缓存,检测达到该使用率则清除一定比例缓存 -bee.osql.cache.fullUsed.rate=0.8 +bee.osql.cache.fullUsedRate=0.8 #添加缓存,检测到缓存容量快满时,删除缓存数的比例 -bee.osql.cache.fullClearCache.rate=0.2 +bee.osql.cache.fullClearRate=0.2 -#仅分库时(bee.dosql.multi-DS.type=2),可用格式: dsName.tableName +#仅分库时(bee.dosql.multiDS.type=2),可用格式: dsName.tableName #use table name, not entity name -#不缓存表的列表, 表名不区分大小写 +#不缓存表的列表, 表名不区分大小写.视图强烈建议不放缓存,因会产生脏数据. #bee.osql.cache.never=user #永久缓存表的列表, 表名不区分大小写 #bee.osql.cache.forever=constant -#永久缓存,但有更改时也会清除缓存,以便同步新的值到缓存. 表名不区分大小写 -#bee.osql.cache.forever.modifySyn=para +#只有更改时才会清除缓存,以便同步新的值到缓存. 表名不区分大小写 +#bee.osql.cache.modifySyn=para # since v1.7.2. default value is: false (use cache) -#bee.osql.cache.nocache=true +#bee.osql.cache.nocache=false +#since 1.8.99 +bee.osql.cache.keyUseMD5=true #cache=======================end ``` @@ -188,8 +190,8 @@ A: 用map进行转换实体信息,查询/删除数据库中的数据. 参考bee-exam项目里: MapSuidExam ```java - MapSuid mapSuid = BeeFactory.getHoneyFactory().getMapSuid(); - MapSql mapSql = BeeFactory.getHoneyFactory().getMapSql(); + MapSuid mapSuid = BeeFactoryHelper.getMapSuid(); + MapSql mapSql = BeeFactoryHelper.getMapSql(); mapSql.put(MapSqlKey.Table, "test_user"); // mapSql.put(MapSqlKey.Table, "testUser"); -- Gitee From c4669203ef8c225729c0ef43a291e7472097cdb8 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Wed, 5 May 2021 23:38:42 +0800 Subject: [PATCH 121/124] add test coverage rate --- README.md | 2 +- README_CN.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 373452b..01a084a 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ 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. +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. diff --git a/README_CN.md b/README_CN.md index 10d1fb8..c437544 100644 --- a/README_CN.md +++ b/README_CN.md @@ -75,7 +75,7 @@ MapSuid,无需Javabean,用map承载需要转换的实体信息,操作数据 增加Ignore注解,忽略Javabean字段,不进行转换. 用模板生成文件支持自定义起止标签. 完善DB连接管理. -加强代码质量. +加强代码质量(测试覆盖率达70%以上,关键代码达90%以上). 增强链式编程:Select,Update. 调整bee.properties,HoneyConfig配置信息. 整合Spring boot,提供bee-spring-boot-starter. -- Gitee From d2c2e897701f93191294b71126f1ccf0eeeaf16a Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 6 May 2021 10:25:00 +0800 Subject: [PATCH 122/124] update quick start for V1.9 --- README.md | 2 +- README_CN.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 01a084a..050b24b 100644 --- a/README.md +++ b/README.md @@ -279,7 +279,7 @@ Quick Start: honey 1.9.5 - + org.teasoft bee-ext diff --git a/README_CN.md b/README_CN.md index c437544..5297ac7 100644 --- a/README_CN.md +++ b/README_CN.md @@ -236,7 +236,7 @@ OrdersService.java honey 1.9.5 - + org.teasoft bee-ext -- Gitee From 2f56b99ecd49555033813541499684e5a8d76e99 Mon Sep 17 00:00:00 2001 From: Kingstar Date: Thu, 6 May 2021 19:12:23 +0800 Subject: [PATCH 123/124] add oneToMany exam --- FAQ_CN.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/FAQ_CN.md b/FAQ_CN.md index f850b3b..fc7a115 100644 --- a/FAQ_CN.md +++ b/FAQ_CN.md @@ -306,6 +306,14 @@ A: 别的ORM框架,将insert与update合为一个save方法,每次操作前 Q: Bee为什么不需要写mapper,dao? A: 这是Bee的一大优势,Bee的编码复杂度是O(1). Bee概念简单,易于使用,编码量少。 Bee通过约定优于配置原则,通过封装,已经简化了开发. + +25. + +Q: Bee一对多查询? +A: Bee一对多查询不需要List. 呈现方式,像我们用DB客户端查询数据,结果是一个二维表. Bee是将这个二维表的每一行封装 +在一个主对象里,每个主对象会有一个从对象保存从表的数据. +详细例子可参考: + https://gitee.com/automvc/bee/wikis/(%E5%85%AD):%20%E5%A4%9A%E8%A1%A8%E6%9F%A5%E8%AF%A2(%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1%E6%96%B9%E5%BC%8F)?sort_id=2309685 **其它相关资源:** -- Gitee From 97c63bec51ac2ca76e04368cc0ae6816c0c9920a Mon Sep 17 00:00:00 2001 From: Kingstar Date: Fri, 7 May 2021 10:14:35 +0800 Subject: [PATCH 124/124] =?UTF-8?q?Bee=E7=AE=80=E5=8C=96=E4=BA=86=E4=B8=8E?= =?UTF-8?q?DB=E4=BA=A4=E4=BA=92=E7=9A=84=E7=BC=96=E7=A0=81=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README_CN.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README_CN.md b/README_CN.md index 5297ac7..5cc3ea8 100644 --- a/README_CN.md +++ b/README_CN.md @@ -24,7 +24,8 @@ https://gitee.com/automvc/bee jdk1.7+ ## Bee主要功能特点介绍: -**Bee概念简单**(10分钟即可入门)、功能强大。 +**Bee概念简单**(10分钟即可入门)、功能强大。 +Bee **简化了与DB交互的编码**工作量.连接,事务都可以由Bee框架负责管理。 * 1.**接口简单,使用方便**。Suid接口中对应SQL语言的select,update,insert,delete操作提供**4个同名方法**。 * 2.使用了Bee,你可以不用再另外编写dao代码,直接调用Bee的api即可完成对DB的操作。 * 3.**约定优于配置**:Javabean没有注解,也不需要xml映射文件,只是纯的Javabean即可,甚至get,set方法不用也可以。 -- Gitee