├── .gitignore ├── 2.0-sharding.md ├── Changed_Log.md ├── Changed_Log_CN.md ├── Changed_Log_Main_CN.md ├── FAQ_CN.md ├── LICENSE ├── MongodbORM-Function-List.md ├── README.md ├── README_CN.md ├── What-is-AiTea.md ├── api doc ├── bee-1.11-CN-javadoc.zip ├── bee-1.11-CN-sources.jar ├── bee-1.11-javadoc.zip ├── bee-1.17-CN-javadoc.zip ├── bee-1.17-CN-sources.jar ├── bee-1.17-javadoc.zip ├── bee-1.9.8-javadoc.zip ├── bee-2.0-javadoc.jar ├── bee-2.1-javadoc.jar └── bee-2.4.0-javadoc.jar ├── doc-weixin.jpg ├── guide ├── FAQ_CN-1.17.md ├── FAQ_CN-before1.8.99.md ├── FAQ_CN-before1.9.8.md ├── FAQ_CN.md ├── Frequently-Used-Guide.md ├── Quick-start-Sharding.md ├── Quick-start-Sharding_CN.md ├── Quick-start-for-Android.md ├── Quick-start-for-Android_CN.md ├── Quick-start-for-Harmony.md ├── Quick-start-for-Harmony_CN.md └── bee-quick-start-2.0.gif ├── illustration ├── AiTea-meaning.png ├── Bee-architecture-EN-V1.11.png ├── Bee-architecture-EN-V1.17.png ├── Bee-architecture-EN-V2.0.png ├── Bee-architecture-V1.11.png ├── Bee-architecture-V1.17.png ├── Bee-architecture-V2.0.png ├── ORM Bee Outline.png ├── batch-insert-compare.png ├── common-interface-2.4.png └── common-interface-2.4_en.png ├── main-feature.md ├── pom.xml ├── src ├── main │ └── java │ │ └── org │ │ └── teasoft │ │ └── bee │ │ ├── android │ │ ├── CreateAndUpgrade.java │ │ └── CreateAndUpgradeRegistry.java │ │ ├── app │ │ └── BeeSqlForApp.java │ │ ├── distribution │ │ ├── GenId.java │ │ ├── Worker.java │ │ └── ds │ │ │ └── Route.java │ │ ├── ds │ │ ├── DataSourceBuilder.java │ │ └── DataSourceBuilderFactory.java │ │ ├── file │ │ ├── FileCreator.java │ │ └── FileReader.java │ │ ├── logging │ │ ├── Log.java │ │ └── Path.java │ │ ├── mongodb │ │ ├── BoxPara.java │ │ ├── CenterPara.java │ │ ├── Geo.java │ │ ├── GridFsFile.java │ │ ├── MongoSqlStruct.java │ │ ├── MongodbBeeSql.java │ │ ├── MongodbRawSql.java │ │ ├── NearPara.java │ │ └── SuidFile.java │ │ ├── mvc │ │ ├── Result.java │ │ └── service │ │ │ ├── ObjSQLAbstractServiceImpl.java │ │ │ ├── ObjSQLRichAbstractServiceImpl.java │ │ │ ├── ObjSQLRichService.java │ │ │ └── ObjSQLService.java │ │ ├── osql │ │ ├── BeeAbstractFactory.java │ │ ├── BeeException.java │ │ ├── BeeExtCache.java │ │ ├── BeeSQLException.java │ │ ├── BeeSql.java │ │ ├── BeeVersion.java │ │ ├── Cache.java │ │ ├── CommOperate.java │ │ ├── ConditionAssistant.java │ │ ├── DatabaseConst.java │ │ ├── FunctionType.java │ │ ├── IncludeType.java │ │ ├── LowerKey.java │ │ ├── MapSqlKey.java │ │ ├── MapSqlSetting.java │ │ ├── MoreObjToSQL.java │ │ ├── NameTranslate.java │ │ ├── ObjSQLException.java │ │ ├── ObjSQLIllegalSQLStringException.java │ │ ├── ObjToSQL.java │ │ ├── ObjToSQLRich.java │ │ ├── OneMethod.java │ │ ├── Op.java │ │ ├── OrderType.java │ │ ├── Properties.java │ │ ├── Registry.java │ │ ├── ResultAssembler.java │ │ ├── ResultAssemblerRegistry.java │ │ ├── Serializer.java │ │ ├── SqlKeyWord.java │ │ ├── SuidType.java │ │ ├── TO_DATE.java │ │ ├── UpperKey.java │ │ ├── annotation │ │ │ ├── AbstractDictI18nDefaultHandler.java │ │ │ ├── AnnotationHandler.java │ │ │ ├── AutoSetString.java │ │ │ ├── BeforeReturnAnnotationHandler.java │ │ │ ├── Column.java │ │ │ ├── ColumnHandler.java │ │ │ ├── Createtime.java │ │ │ ├── Datetime.java │ │ │ ├── Desensitize.java │ │ │ ├── Dict.java │ │ │ ├── DictI18n.java │ │ │ ├── DsTabHandler.java │ │ │ ├── Entity.java │ │ │ ├── FK.java │ │ │ ├── GenId.java │ │ │ ├── GenUUID.java │ │ │ ├── Geo2dsphere.java │ │ │ ├── GridFs.java │ │ │ ├── GridFsMetadata.java │ │ │ ├── Ignore.java │ │ │ ├── JoinTable.java │ │ │ ├── JoinType.java │ │ │ ├── Jsonb.java │ │ │ ├── JustFetch.java │ │ │ ├── MultiTenancy.java │ │ │ ├── PrimaryKey.java │ │ │ ├── ReplaceInto.java │ │ │ ├── Sharding.java │ │ │ ├── SysValue.java │ │ │ ├── Table.java │ │ │ ├── Updatetime.java │ │ │ └── customizable │ │ │ │ ├── Json.java │ │ │ │ └── JsonHandler.java │ │ ├── api │ │ │ ├── CallableSql.java │ │ │ ├── Condition.java │ │ │ ├── MapSql.java │ │ │ ├── MapSuid.java │ │ │ ├── MoreTable.java │ │ │ ├── PreparedSql.java │ │ │ ├── Suid.java │ │ │ ├── SuidRich.java │ │ │ └── cqrs │ │ │ │ ├── Command.java │ │ │ │ └── Query.java │ │ ├── chain │ │ │ ├── Delete.java │ │ │ ├── Insert.java │ │ │ ├── Select.java │ │ │ ├── ToSql.java │ │ │ ├── UnionSelect.java │ │ │ ├── Update.java │ │ │ └── Where.java │ │ ├── dialect │ │ │ ├── DbFeature.java │ │ │ └── DbFeatureRegistry.java │ │ ├── exception │ │ │ ├── BeeErrorFieldException.java │ │ │ ├── BeeErrorGrammarException.java │ │ │ ├── BeeErrorNameException.java │ │ │ ├── BeeIllegalAccessException.java │ │ │ ├── BeeIllegalBusinessException.java │ │ │ ├── BeeIllegalEntityException.java │ │ │ ├── BeeIllegalParameterException.java │ │ │ ├── BeeIllegalSQLException.java │ │ │ ├── BeeInstantiationException.java │ │ │ ├── ConfigWrongException.java │ │ │ ├── JoinTableException.java │ │ │ ├── JoinTableParameterException.java │ │ │ ├── NoConfigException.java │ │ │ ├── NotSupportedException.java │ │ │ ├── ShardingErrorException.java │ │ │ └── SqlNullException.java │ │ ├── interccept │ │ │ ├── Interceptor.java │ │ │ └── InterceptorChain.java │ │ ├── search │ │ │ ├── Operator.java │ │ │ └── Search.java │ │ ├── token │ │ │ └── CustomAutoSqlToken.java │ │ ├── transaction │ │ │ ├── Tran.java │ │ │ ├── Transaction.java │ │ │ └── TransactionIsolationLevel.java │ │ └── type │ │ │ ├── PostgreSQLJsonString.java │ │ │ ├── PostgreSQLJsonbString2.java │ │ │ ├── SetParaTypeConvert.java │ │ │ └── TypeHandler.java │ │ ├── sharding │ │ ├── DsTabStruct.java │ │ ├── FunStruct.java │ │ ├── GroupFunStruct.java │ │ ├── ShardingBean.java │ │ ├── ShardingPageStruct.java │ │ ├── ShardingSimpleStruct.java │ │ ├── ShardingSortStruct.java │ │ └── algorithm │ │ │ ├── Calculate.java │ │ │ └── CalculateRegistry.java │ │ └── spi │ │ ├── AnnoAdapter.java │ │ ├── JsonTransform.java │ │ ├── PreLoad.java │ │ ├── SqlFormat.java │ │ └── defaultimpl │ │ └── AnnoAdapterBeeDefault.java └── test │ └── java │ └── org │ └── teasoft │ └── bee │ ├── BeeExam.java │ └── change-log.txt └── weixin.jpg /.gitignore: -------------------------------------------------------------------------------- 1 | /.settings 2 | /target 3 | /.classpath 4 | /.project 5 | /pom.xml-maven 6 | /pom.xml-maven1.9.8提交用 7 | /.gitignore 8 | -------------------------------------------------------------------------------- /MongodbORM-Function-List.md: -------------------------------------------------------------------------------- 1 | Mongodb ORM(Bee) 2 | ========= 3 | Mongodb ORM 是Bee提供众多ORM功能的一部分; 4 | Bee,互联网新时代的Java ORM框架, 5 | 同时支持JDBC(比如JavaWeb),Android和Harmony; 6 | 支持Sharding分片; 7 | 支持多种关系型数据库(MySQL,MariaDB,Oracle,H2,SQLite,PostgreSQL,SQL Server,Access,金仓,达梦等), 8 | 还支持NoSQL的Cassandra,Mongodb等. 9 | 10 | 11 | ## Mongodb ORM-Function-List 12 | **Bee 2.0 起,开始支持MongoDB和分片.** 13 | #### Mongodb ORM(Bee)支持功能 14 | Bee使用ORM面向对象方式操作Mongodb支持接口: 15 | Suid 16 | SuidRich 17 | SuidRichExt/MongodbSuidRichExt 18 | 支持打印可执行的原生语句日志 19 | 20 | 非分片情况下,以上四个接口的方法都适合在Mongodb使用. 21 | 兼容支持JDBC数据源(Mongodb JDBC) 22 | 支持数字ID(Long,Int),支持全局唯一的数字ID 23 | 分片支持: 24 | DDL创建集合Collection(表) 25 | 生成集合(表)对应的Javabean(可一行代码生成整个库的表) 26 | sharding分片查询: 27 | 查询聚合函数的分片 28 | 查询操作返回结果是List类型的分片(分片的select操作) 29 | 查询操作返回结果是List类型的分片 30 | 查询操作返回结果是Json字符串类型的分片(selectJson的分片) 31 | 批量插入分片 32 | 广播表批量插入所有库 33 | 分片键分片支持的运算符 34 | =,in,between;其中in支持Number,List,Set 35 | 注意不参与分片:not in, not between,>=,<= 36 | 使用MongodbRawSql接口可直接执行原生语句(Mongodb shell命令) 37 | 事务 38 | 创建索引,删除索引 39 | 支持查询嵌入式文档 40 | 地理信息插入、查询 41 | 42 | #### Mongodb ORM(Bee)(V2.0,V2.1)未支持功能: 43 | 多表查询MoreTable(使用单表查询嵌入式文档即可). 44 | 广播表的更改;(可以自行多次设置库名并调用更改方法) 45 | sharding分组汇总查询 46 | sharding分片更改操作中:单条插入,更新,删除的分片操作(可以自行多次设置库名并调用更改方法) 47 | 48 | 49 | #### 常识: 50 | **Mongodb与RDB的概念对应关系** 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 |
Mongodb 关系型数据库
集合(Collectioin) 表(Table)
文档(Documnet)  记录/一行记录(Record)
68 | 69 | 70 | -------------------------------------------------------------------------------- /What-is-AiTea.md: -------------------------------------------------------------------------------- 1 | **Bee** 是一个具有人工智能(**AI**)特性,**省时/优雅、简易、自动**( **AiTea:** Timesaving/Tasteful, Easy, Automatic) 的ORM软件框架(AiTeaSoft)(IT-->AiTea 的思维转变!)。 2 | 3 | Bee是一种更接近SQL语言思维的ORM框架, 4 | 一种开发速度和开发成本都不比Php,Ruby on Rail差的Java ORM框架, 5 | 而且它的编码复杂度是O(1),即用了Bee,**无论多少个表**,你都可以不用另外再写dao代码;**让你可以更专注业务逻辑的开发**。 -------------------------------------------------------------------------------- /api doc/bee-1.11-CN-javadoc.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/automvc/bee/0892f33f513a30117fce7129706898510b48907c/api doc/bee-1.11-CN-javadoc.zip -------------------------------------------------------------------------------- /api doc/bee-1.11-CN-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/automvc/bee/0892f33f513a30117fce7129706898510b48907c/api doc/bee-1.11-CN-sources.jar -------------------------------------------------------------------------------- /api doc/bee-1.11-javadoc.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/automvc/bee/0892f33f513a30117fce7129706898510b48907c/api doc/bee-1.11-javadoc.zip -------------------------------------------------------------------------------- /api doc/bee-1.17-CN-javadoc.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/automvc/bee/0892f33f513a30117fce7129706898510b48907c/api doc/bee-1.17-CN-javadoc.zip -------------------------------------------------------------------------------- /api doc/bee-1.17-CN-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/automvc/bee/0892f33f513a30117fce7129706898510b48907c/api doc/bee-1.17-CN-sources.jar -------------------------------------------------------------------------------- /api doc/bee-1.17-javadoc.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/automvc/bee/0892f33f513a30117fce7129706898510b48907c/api doc/bee-1.17-javadoc.zip -------------------------------------------------------------------------------- /api doc/bee-1.9.8-javadoc.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/automvc/bee/0892f33f513a30117fce7129706898510b48907c/api doc/bee-1.9.8-javadoc.zip -------------------------------------------------------------------------------- /api doc/bee-2.0-javadoc.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/automvc/bee/0892f33f513a30117fce7129706898510b48907c/api doc/bee-2.0-javadoc.jar -------------------------------------------------------------------------------- /api doc/bee-2.1-javadoc.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/automvc/bee/0892f33f513a30117fce7129706898510b48907c/api doc/bee-2.1-javadoc.jar -------------------------------------------------------------------------------- /api doc/bee-2.4.0-javadoc.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/automvc/bee/0892f33f513a30117fce7129706898510b48907c/api doc/bee-2.4.0-javadoc.jar -------------------------------------------------------------------------------- /doc-weixin.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/automvc/bee/0892f33f513a30117fce7129706898510b48907c/doc-weixin.jpg -------------------------------------------------------------------------------- /guide/Quick-start-Sharding.md: -------------------------------------------------------------------------------- 1 | Sharing Sharing better example 2 | 3 | 4 | 1.Sharing better example 5 | 6 | ```java 7 | 8 | //1. Sharding config 9 | 10 | ShardingConfig.addShardingBean(Orders.class,new ShardingBean("ds[0..1].orders[0..5]", "userid")); 11 | 12 | //2. query 13 | 14 | Suid suid=BF.getSuid(); // get select,update,insert,delete instance 15 | 16 | Orders orders1=new Orders(); 17 | 18 | orders1.setUserid(3L); // Sharding value 19 | 20 | List list=suid.select(orders1,condition); // query Orders entity list 21 | 22 | ``` 23 | 24 | eg:"ds [0..1].orders [0..5]", "userid" mean there are two dataSources:ds0, ds1; ds0 has:orders0,orders1,orders2; 25 | ds1 has:orders3,orders4,orders5; table sharding field:userid; 26 | 默认是根据表分片键(字段)的值,来路由到相应的表,如 条件 where userid =3, 则 3%6=3, 就会路由到表 orders3。Bee 默认还支持分片值是 String 的类型。 27 | 28 | 示例中,“//2. 查询” 注释的部分代码,是原来数据库没有分片时,ORM 用来查询的代码。在分片的情况下,只需要添加 “//1. 分片配置” 部分的代码即可; 29 | 该部分是 Java 风格的配置,也可以使用 properties 风格的方式进行添加配置信息。 30 | 31 | 32 | 2. Bee relative config 33 | 34 | ```properties 35 | 36 | #Bee Sharding enable 37 | bee.dosql.multiDS.enable=true 38 | bee.dosql.multiDS.sharding=true 39 | # since v2.0 enable Sharding log 40 | bee.osql.showSQL=true 41 | bee.osql.showShardingSQL=true 42 | 43 | ``` 44 | -------------------------------------------------------------------------------- /guide/Quick-start-Sharding_CN.md: -------------------------------------------------------------------------------- 1 | 分库分表 Sharding: 6. Sharing 最佳实践参考实例 2 | 3 | 4 | 5 | 1.Sharing 最佳实践参考实例 6 | 7 | ```java 8 | 9 | //1. 分片配置 10 | 11 | ShardingConfig.addShardingBean(Orders.class,new ShardingBean("ds[0..1].orders[0..5]", "userid")); 12 | 13 | //2. 查询 14 | 15 | Suid suid=BF.getSuid(); // 获取 select,update,insert,delete 操作对象 16 | 17 | Orders orders1=new Orders(); 18 | 19 | orders1.setUserid(3L); // 分片值 20 | 21 | List list=suid.select(orders1,condition); // 查询 Orders 实体列表 22 | 23 | ``` 24 | 25 | 其中:"ds [0..1].orders [0..5]", "userid" 表示,数据源有:ds0, ds1; ds0 里有:orders0,orders1,orders2; ds1 里有表:orders3,orders4,orders5; 表的分片键是:userid; 默认是根据表分片键(字段)的值,来路由到相应的表,如 条件 where userid =3, 则 3%6=3, 就会路由到表 orders3。Bee 默认还支持分片值是 String 的类型。 26 | 27 | 示例中,“//2. 查询” 注释的部分代码,是原来数据库没有分片时,ORM 用来查询的代码。在分片的情况下,只需要添加 “//1. 分片配置” 部分的代码即可;该部分是 Java 风格的配置,也可以使用 properties 风格的方式进行添加配置信息。 28 | 29 | 30 | 2. Bee 使用分片的相关配置 31 | 32 | ```properties 33 | #Bee 使用分片的相关配置: 34 | #开启 Bee Sharding 分片功能进行分库分表 35 | bee.dosql.multiDS.enable=true 36 | bee.dosql.multiDS.sharding=true 37 | # since v2.0 开启 Sharding 日志 38 | bee.osql.showSQL=true 39 | bee.osql.showShardingSQL=true 40 | 41 | ``` 42 | -------------------------------------------------------------------------------- /guide/Quick-start-for-Android.md: -------------------------------------------------------------------------------- 1 | Android环境使用Bee 2 | 3 | 1. bee.properties 4 | 5 | ```properties 6 | bee.db.isAndroid=true 7 | bee.db.androidDbName=account.db 8 | bee.db.androidDbVersion=1 9 | bee.osql.loggerType=androidLog 10 | #开启查询结果字段类型转换,将支持更多类型 11 | bee.osql.openFieldTypeHandler=true 12 | 13 | #如果允许删除和更新整张表,需要开启 14 | #bee.osql.notDeleteWholeRecords=false 15 | #bee.osql.notUpdateWholeRecords=false 16 | bee.osql.openFieldTypeHandler=true 17 | 18 | ``` 19 | 20 | 2.实现app安装及升级需要创建和更新的表 21 | 22 | ```java 23 | public class YourAppCreateAndUpgrade implements CreateAndUpgrade{ 24 |     @Override 25 |     public void onCreate() { 26 | //        可以使用面向对象方式创建表 27 |         Ddl.createTable(new Orders(), false); 28 |         Ddl.createTable(new TestUser(), false); 29 |     } 30 | 31 |     @Override 32 |     public void onUpgrade(int oldVersion, int newVersion) { 33 |         if(newVersion==2) { 34 |             Ddl.createTable(new LeafAlloc(), true); 35 |             Log.i("onUpgrade", "你在没有卸载的情况下,在线更新到版本:"+newVersion); 36 |         } 37 |     } 38 | } 39 | 40 | 41 | ``` 42 | 43 | 3.将YourAppCreateAndUpgrade和Android上下文注册到Bee     并在AndroidManifest.xml,配置android:name为BeeApplication 44 | 45 | ```java 46 | package com.aiteasoft.util; 47 | 48 | import org.teasoft.bee.android.CreateAndUpgradeRegistry; 49 | import org.teasoft.beex.android.ApplicationRegistry; 50 | 51 | public class BeeApplication extends Application { 52 |     private static Context context; 53 |     @Override 54 |     public void onCreate() { 55 |        ApplicationRegistry.register(this);//注册上下文 56 |        CreateAndUpgradeRegistry.register(YourAppCreateAndUpgrade.class); 57 |     } 58 |  } 59 |   60 | // 并在AndroidManifest.xml,配置android:name为BeeApplication  61 |   66 | 67 | ``` 68 | 69 | 4. Java操作SQLite数据库与JavaWeb类似. 70 | 操作数据库时, 不需要每次都传递Context到ORM框架.使用非常简单易用;性能也不差. 71 | ```java 72 | Suid suid=BF.getSuid(); 73 | List list = suid.select(new Orders()); 74 | ``` 75 | 76 | 77 | 对比: 78 | 其它Android ORM工具: 79 | 需要用户为每个表封装dao. 80 | 每次都要传递当前Activity。 81 | 如: 82 | new UserDao(MainActivity.this).insert(userData); 83 | UserBean userBean = new UserDao(MainActivity.this).queryById(articleBean.getUser().getId()); 84 | -------------------------------------------------------------------------------- /guide/bee-quick-start-2.0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/automvc/bee/0892f33f513a30117fce7129706898510b48907c/guide/bee-quick-start-2.0.gif -------------------------------------------------------------------------------- /illustration/AiTea-meaning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/automvc/bee/0892f33f513a30117fce7129706898510b48907c/illustration/AiTea-meaning.png -------------------------------------------------------------------------------- /illustration/Bee-architecture-EN-V1.11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/automvc/bee/0892f33f513a30117fce7129706898510b48907c/illustration/Bee-architecture-EN-V1.11.png -------------------------------------------------------------------------------- /illustration/Bee-architecture-EN-V1.17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/automvc/bee/0892f33f513a30117fce7129706898510b48907c/illustration/Bee-architecture-EN-V1.17.png -------------------------------------------------------------------------------- /illustration/Bee-architecture-EN-V2.0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/automvc/bee/0892f33f513a30117fce7129706898510b48907c/illustration/Bee-architecture-EN-V2.0.png -------------------------------------------------------------------------------- /illustration/Bee-architecture-V1.11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/automvc/bee/0892f33f513a30117fce7129706898510b48907c/illustration/Bee-architecture-V1.11.png -------------------------------------------------------------------------------- /illustration/Bee-architecture-V1.17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/automvc/bee/0892f33f513a30117fce7129706898510b48907c/illustration/Bee-architecture-V1.17.png -------------------------------------------------------------------------------- /illustration/Bee-architecture-V2.0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/automvc/bee/0892f33f513a30117fce7129706898510b48907c/illustration/Bee-architecture-V2.0.png -------------------------------------------------------------------------------- /illustration/ORM Bee Outline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/automvc/bee/0892f33f513a30117fce7129706898510b48907c/illustration/ORM Bee Outline.png -------------------------------------------------------------------------------- /illustration/batch-insert-compare.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/automvc/bee/0892f33f513a30117fce7129706898510b48907c/illustration/batch-insert-compare.png -------------------------------------------------------------------------------- /illustration/common-interface-2.4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/automvc/bee/0892f33f513a30117fce7129706898510b48907c/illustration/common-interface-2.4.png -------------------------------------------------------------------------------- /illustration/common-interface-2.4_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/automvc/bee/0892f33f513a30117fce7129706898510b48907c/illustration/common-interface-2.4_en.png -------------------------------------------------------------------------------- /main-feature.md: -------------------------------------------------------------------------------- 1 | ## Bee主要功能特点介绍: 2 | **Bee概念简单**(10分钟即可入门)、功能强大。 3 | Bee **简化了与DB交互的编码**工作量。连接,事务都可以由Bee框架负责管理。 4 | 简单易用,文件小,性能好;同时支持**JDBC(比如JavaWeb),Android和Harmony,NoSQL(Cassandra,MongoDB)**。 5 | #### 简单易用,省时,开发速度快 6 | * 1.**接口简单,使用方便**。Suid接口中对应SQL语言的select,update,insert,delete操作提供**4个同名方法**。 7 | * 2.使用了Bee,你可以不用再另外编写dao代码,直接调用Bee的api即可完成对DB的操作。 8 | * 3.**约定优于配置**:Javabean没有注解,也不需要xml映射文件,只是纯的Javabean即可,甚至get,set方法不用也可以。 9 | * 4.**智能化自动过滤**实体的null和空字符串属性,不再需要写判断非空的代码。 10 | * 5.可轻松实现**只查询一部分字段**,轻松实现**原生语句分页**。 11 | * 6.支持**直接返回Json**格式查询结果; 链式编程。 12 | * 7.**Sharding分片**,分库分表;只分库;只分表;读写分离;(对以前的代码无需修改,该功能对代码是透明的,即无需额外编码)。 13 | * 8.**多种DB**支持轻松扩展(MySQL,MariaDB,Oracle,H2,SQLite,PostgreSQL,SQL Server,Access,金仓,达梦等,NoSQL:**Cassandra,Mongodb**等直接可用),理论上支持JDBC的DB都可以支持,此外还支持**Android和Harmony**,支持ElasticSearch(7.x) ORM 查询; 14 | * 9.更多数据库分页默认支持:MsAccess,Cubrid,HSQL,Derby,Firebird等 15 | * 10.**多种数据库可同时使用(如同时使用Mysql,Oracle,MongoDB)**。 16 | 17 | #### 自动,功强强大 18 | * 11.**动态/任意组合**查询条件,不需要提前准备dao接口,有新的查询需求也不用修改或添加接口。 19 | * 12.支持**事务**、多个ORM操作使用同一连接、**for update**,支持**批处理**操作,支持原生SQL(**自定义sql**语句),支持**存储过程**。 20 | * 13.支持面向对象方式复杂查询、**多表查询**(无n+1问题; 支持:一对一,一对多,多对一,多对多;返回结果根据子表是否使用List有两种呈现结构);多表关联改插删(2.1.8)。 21 | * 14.Mongodb ORM,Mongodb分库分表。 22 | * 15.**注册器、拦截器、多租户,支持自定义TypeHandler,处理查询的ResultSet结果**; 23 | 转换器SetParaTypeConvert转换PreparedStatement参数的类型。 24 | * 16.自定义动态SQL标签,@in,@toIsNULL1,@toIsNULL2,<if isNotNull>,<if isNotBlank>; 25 | 动态sql,将list转为像in (1,2,3)的语句,不需要foreach,批量插入也不需要foreach。 26 | * 17.复杂查询前后端可自动解析。 27 | * 18.**一级缓存**,概念简单,功能强大;一级缓存也可以**像JVM一样进行细粒度调优**;**支持可更新的长久缓存列表**,更新配置表,**不需要重启**。天生抵御缓存穿透 。 28 | **二级缓存扩展支持;内置Redis二级缓存支持**。 29 | * 19.**无**第三方插件依赖;可零配置使用。 30 | * 20.**性能好:接近JDBC的速度;文件小:Bee V1.17 仅502k**, **V2.1 仅827k**。 31 | 32 | **辅助功能**: 33 | * 21.提供自然简单的分布式主键生成方案:**分布式**环境下生成**连续单调递增**(在一个workerid内),**全局唯一**数字**id**。 34 | * 22.支持自动生成表对应的Javabean(支持Swagger),根据Javabean创建表,Javaweb**后端代码**根据**模板自动生成**;能打印非占位符的**可执行sql(支持sql格式化)**,方便调试;支持生成Json格式的SQL脚本。 35 | * 23.支持**读取Excel**,从Excel导入数据到DB,操作简单;支持从Excel获取配置生成数据库表。 36 | * 24.流的工具类StreamUtil,DateUtil日期转换,判断日期格式,计算年龄。 37 | * 25.丰富的注解支持:PrimaryKey,Column,Datetime,Createtime,Updatetime;JustFetch,ReplaceInto(MySQL),Dict,DictI18n,GridFs等。 38 | * 26.使用实体名_F(自动生成)引用实体字段名Users_F.name或在SuidRichExt接口中使用格式如Users::getName。 -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | org.teasoft 5 | bee 6 | 2.5.2 7 | jar 8 | 9 | 10 | UTF-8 11 | 1.7 12 | 1.7 13 | 14 | 15 | 16 | 17 | 18 | org.apache.maven.plugins 19 | maven-jar-plugin 20 | 3.0.0 21 | 22 | 23 | 24 | 25 | org.apache.maven.plugins 26 | maven-source-plugin 27 | 3.0.0 28 | 29 | 30 | attach-sources 31 | 32 | jar 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | org.apache.maven.plugins 41 | maven-javadoc-plugin 42 | 3.0.0 43 | 44 | UTF-8 45 | UTF-8 46 | UTF-8 47 | en_US 48 | -Xdoclint:none 49 | none 50 | 51 | 52 | 53 | package 54 | 55 | jar 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/android/CreateAndUpgrade.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.android; 19 | 20 | /** 21 | * Create and Upgrade. 22 | * @author Kingstar 23 | * @since 1.17 24 | */ 25 | public interface CreateAndUpgrade { 26 | 27 | /** 28 | * Called when the database is created for the first time. This is where the 29 | * creation of tables and the initial population of the tables should happen. 30 | */ 31 | public void onCreate(); 32 | 33 | /** 34 | * Called when the database needs to be upgraded. The implementation 35 | * should use this method to drop tables, add tables, or do anything else it 36 | * needs to upgrade to the new schema version. 37 | * 38 | *

If you add new columns you can use ALTER TABLE to insert them into a live table. 39 | * If you rename or remove columns you can use ALTER TABLE to rename the old table, 40 | * then create the new table and then populate the new table with the contents of the old table. 41 | *

42 | * This method executes within a transaction. If an exception is thrown, all changes 43 | * will automatically be rolled back. 44 | *

45 | * 46 | * @param oldVersion The old database version. 47 | * @param newVersion The new database version. 48 | */ 49 | public void onUpgrade(int oldVersion, int newVersion); 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/android/CreateAndUpgradeRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.android; 19 | 20 | /** 21 | * CreateAndUpgrade Registry 22 | * @author Kingstar 23 | * @since 1.17 24 | */ 25 | public class CreateAndUpgradeRegistry { 26 | 27 | private static Class clazz; 28 | 29 | private CreateAndUpgradeRegistry() {} 30 | 31 | /** 32 | * 33 | * @param c registry class 34 | */ 35 | public static void register(Class c) { 36 | clazz = c; 37 | } 38 | 39 | /** 40 | * return the registry class 41 | * @return the registry class implement CreateAndUpgrade 42 | */ 43 | public static Class getCreateAndUpgrade() { 44 | return clazz; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/distribution/GenId.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2020 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.distribution; 19 | 20 | /** 21 | * 22 | * Generate global unique id number in distributed environment. 23 | * GUID : Global Unique ID. 24 | * 25 |

--------------------------------------------- 26 |

org.teasoft.honey.distribution.PearFlowerId 27 | 28 |

--------------------------------------------- 29 |

org.teasoft.honey.distribution.SerialUniqueId 30 | * Serial Unique Id in one workerid. 31 | * Advantages:continuous and unique;less clock dependent.Implemented in dB, it can achieve auto increment 32 | * of distributed global unique ID in dB. The ID number get in the same workerid can satisfy continuous 33 | * monotonic increasing uniqueness. 34 | * Shortcoming:worker1's ID --------------------------------------------- 37 |

org.teasoft.honey.distribution.OneTimeSnowflakeId 38 | 39 | * @author Kingstar 40 | * @since 1.7.2 41 | */ 42 | public interface GenId { 43 | 44 | /** 45 | * return the id number. 46 | * @return long id number. 47 | */ 48 | public long get(); 49 | 50 | /** 51 | * Get a segment of numbers at a time and return the minimum and maximum available numbers of a batch. 52 | *
eg: [100000,101000],array[0]=100000,array[1]=101000. 53 | *
In some algorithms, such as:PearFlowerId,OneTimeSnowflakeId, 54 | *
1) The parameter sizeOfIds should not be greater than 8192. 55 | *
2) In order to make array[0]=min,array[1]=max in the range of series, it is possible to waste id number; 56 | *
if you don't want to, you can loop call the get() method or use SerialUniqueId algorithm. 57 | *
The SerialUniqueId algorithm does not have the above two problems. 58 | * @param sizeOfIds the size Of ids in one batch. 59 | * @return return the array of long. array[0]=min,array[1]=max. 60 | */ 61 | public long[] getRangeId(int sizeOfIds); 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/distribution/Worker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2020 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.distribution; 19 | 20 | /** 21 | * uniquely identify the ID generator running in an application. 22 | * @author Kingstar 23 | * @since 1.7.2 24 | */ 25 | public interface Worker { 26 | 27 | /** 28 | * get long number of unique worker ID. 29 | * @return long number of unique worker ID. 30 | */ 31 | long getWorkerId(); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/distribution/ds/Route.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2020 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.distribution.ds; 19 | 20 | /** 21 | * the route interface of multi-DataSource. 22 | * @author Kingstar 23 | * @since 1.8 24 | */ 25 | public interface Route { 26 | 27 | /** 28 | * Return the name of DataSource. 29 | * @return the name of DataSource. 30 | */ 31 | public String getDsName(); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/ds/DataSourceBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2023 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.ds; 19 | 20 | import java.util.Map; 21 | 22 | import javax.sql.DataSource; 23 | 24 | /** 25 | * DataSource Builder. 26 | * @author Kingstar 27 | * @since 2.1 28 | */ 29 | public interface DataSourceBuilder { 30 | 31 | public DataSource build(Map propertiesMap); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/ds/DataSourceBuilderFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2023 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.ds; 19 | 20 | import java.util.Map; 21 | import java.util.concurrent.ConcurrentHashMap; 22 | 23 | import org.teasoft.bee.osql.Registry; 24 | 25 | /** 26 | * DataSource Builder Factory. 27 | * @author Kingstar 28 | * @since 2.1 29 | */ 30 | public class DataSourceBuilderFactory implements Registry { 31 | 32 | private static Map map = null; 33 | 34 | private DataSourceBuilderFactory() {} 35 | 36 | public static void register(String dataSourceToolType, DataSourceBuilder builder) { 37 | if (map == null) initMap(); 38 | if (dataSourceToolType != null) dataSourceToolType = dataSourceToolType.toLowerCase(); 39 | if (map != null) map.put(dataSourceToolType, builder); 40 | } 41 | 42 | private static synchronized void initMap() { 43 | map = new ConcurrentHashMap<>(); 44 | } 45 | 46 | public static DataSourceBuilder getDataSourceBuilder(String dataSourceToolType) { 47 | return map == null ? null : map.get(dataSourceToolType.toLowerCase()); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/file/FileCreator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2020 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.file; 19 | 20 | /** 21 | * File creator interface. 22 | * @author Kingstar 23 | * @since 1.7.1 24 | */ 25 | public interface FileCreator extends FileReader{ 26 | /** 27 | * Write content to generated file. Can override the file if it exists. 28 | * @param fullPathAndName All paths, including file names 29 | * @param content file of content 30 | */ 31 | public void genFile(String fullPathAndName, String content); 32 | 33 | /** 34 | * Write content to generated file. Can override the file if it exists. 35 | * @param fullPath full path 36 | * @param fileName file name 37 | * @param content file of content 38 | */ 39 | public void genFile(String fullPath, String fileName, String content); 40 | 41 | /** 42 | * Write content to generated file. Can override the file if it exists. 43 | * @param basePath base path 44 | * @param packagePath package path 45 | * @param fileName file name 46 | * @param content file of content 47 | */ 48 | public void genFile(String basePath,String packagePath, String fileName, String content); 49 | 50 | 51 | /** 52 | * Append content to the end of the file. 53 | * @param fullPathAndName All paths, including file names 54 | * @param content file of content 55 | * @since 1.7.2 56 | */ 57 | public void genAppendFile(String fullPathAndName, String content); 58 | 59 | /** 60 | * set charsetName 61 | * @param charsetName charset name 62 | * @since 1.8.9 63 | */ 64 | public void setCharsetName(String charsetName); 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/file/FileReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2020 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.file; 19 | 20 | import java.io.BufferedReader; 21 | import java.io.File; 22 | 23 | /** 24 | * Easy class of Read file by fullPathAndName. 25 | * @author Kingstar 26 | * @since 1.7.2 27 | */ 28 | public interface FileReader { 29 | 30 | /** 31 | * read the file by fullPathAndName. 32 | * @param fullPathAndName All paths, including file names 33 | * @return instance of BufferedReader 34 | */ 35 | public BufferedReader readFile(String fullPathAndName); 36 | 37 | /** 38 | * read the file. 39 | * @param file 40 | * @return instance of BufferedReader 41 | * @since 1.11 42 | */ 43 | public BufferedReader readFile(File file); 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/logging/Log.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2020 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.logging; 19 | 20 | /** 21 | * Log interface. 22 | * @author Kingstar 23 | * @since 1.4 24 | */ 25 | public interface Log { 26 | 27 | public boolean isTraceEnabled(); 28 | 29 | /** 30 | * Log a message at the TRACE level. 31 | * 32 | * @param msg the message string to be logged 33 | */ 34 | public void trace(String msg); 35 | 36 | public boolean isDebugEnabled(); 37 | 38 | /** 39 | * Log a message at the DEBUG level. 40 | * 41 | * @param msg the message string to be logged 42 | */ 43 | public void debug(String msg); 44 | public void debug(String msg, Throwable t); 45 | 46 | public boolean isInfoEnabled(); 47 | 48 | /** 49 | * Log a at the INFO level. 50 | * 51 | * @param msg the message string to be logged 52 | */ 53 | public void info(String msg); 54 | 55 | public boolean isWarnEnabled(); 56 | 57 | /** 58 | * Log a message at the level. 59 | * 60 | * @param msg the message string to be logged 61 | */ 62 | public void warn(String msg); 63 | public void warn(String msg, Throwable t); 64 | 65 | public boolean isErrorEnabled(); 66 | 67 | /** 68 | * Log a message at the ERROR level. 69 | * 70 | * @param msg the message string to be logged 71 | */ 72 | public void error(String msg); 73 | 74 | public void error(String msg, Throwable t); 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/logging/Path.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2020 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.logging; 19 | 20 | /** 21 | * Set the log file path(include file name). 22 | * @author Kingstar 23 | * @since 1.7.2 24 | */ 25 | public class Path { 26 | 27 | private static String fullPath=""; 28 | 29 | private Path() {} 30 | 31 | public static String getFullPath(){ 32 | return fullPath; 33 | } 34 | 35 | public static void setFullPath(String fullPath) { 36 | Path.fullPath = fullPath; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/mongodb/BoxPara.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2023 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.mongodb; 19 | 20 | /** 21 | * Box Parameter struct for Mongodb Geo. 22 | * @author Kingstar 23 | * @since 2.1 24 | */ 25 | public class BoxPara { 26 | 27 | private String geoFieldName; 28 | private double lowerLeftX; 29 | private double lowerLeftY; 30 | private double upperRightX; 31 | private double upperRightY; 32 | 33 | public BoxPara() {} 34 | 35 | public BoxPara(String geoFieldName, double lowerLeftX, double lowerLeftY, 36 | double upperRightX, double upperRightY) { 37 | 38 | this.geoFieldName = geoFieldName; 39 | this.lowerLeftX = lowerLeftX; 40 | this.lowerLeftY = lowerLeftY; 41 | this.upperRightX = upperRightX; 42 | this.upperRightY = upperRightY; 43 | } 44 | 45 | public String getGeoFieldName() { 46 | return geoFieldName; 47 | } 48 | 49 | public void setGeoFieldName(String geoFieldName) { 50 | this.geoFieldName = geoFieldName; 51 | } 52 | 53 | public double getLowerLeftX() { 54 | return lowerLeftX; 55 | } 56 | 57 | public void setLowerLeftX(double lowerLeftX) { 58 | this.lowerLeftX = lowerLeftX; 59 | } 60 | 61 | public double getLowerLeftY() { 62 | return lowerLeftY; 63 | } 64 | 65 | public void setLowerLeftY(double lowerLeftY) { 66 | this.lowerLeftY = lowerLeftY; 67 | } 68 | 69 | public double getUpperRightX() { 70 | return upperRightX; 71 | } 72 | 73 | public void setUpperRightX(double upperRightX) { 74 | this.upperRightX = upperRightX; 75 | } 76 | 77 | public double getUpperRightY() { 78 | return upperRightY; 79 | } 80 | 81 | public void setUpperRightY(double upperRightY) { 82 | this.upperRightY = upperRightY; 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/mongodb/CenterPara.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2023 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.mongodb; 19 | 20 | /** 21 | * Center parameter struct for Mongodb Geo. 22 | * @author Kingstar 23 | * @since 2.1 24 | */ 25 | public class CenterPara { 26 | 27 | private String geoFieldName; 28 | private double x; 29 | private double y; 30 | private double radius; 31 | 32 | public CenterPara() {} 33 | 34 | public CenterPara(String geoFieldName, double x, double y, double radius) { 35 | 36 | this.geoFieldName = geoFieldName; 37 | this.x = x; 38 | this.y = y; 39 | this.radius = radius; 40 | } 41 | 42 | public String getGeoFieldName() { 43 | return geoFieldName; 44 | } 45 | 46 | public void setGeoFieldName(String geoFieldName) { 47 | this.geoFieldName = geoFieldName; 48 | } 49 | 50 | public double getX() { 51 | return x; 52 | } 53 | 54 | public void setX(double x) { 55 | this.x = x; 56 | } 57 | 58 | public double getY() { 59 | return y; 60 | } 61 | 62 | public void setY(double y) { 63 | this.y = y; 64 | } 65 | 66 | public double getRadius() { 67 | return radius; 68 | } 69 | 70 | public void setRadius(double radius) { 71 | this.radius = radius; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/mongodb/Geo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2023 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.mongodb; 19 | 20 | import java.util.List; 21 | 22 | import org.teasoft.bee.osql.api.Condition; 23 | 24 | /** 25 | * Interface for Mongodb Geo. 26 | * @author Kingstar 27 | * @since 2.1 28 | */ 29 | public interface Geo { 30 | 31 | public List geoWithinPolygon(T entity,String fieldName, final List> points,Condition condition); 32 | 33 | public List near(T entity,NearPara nearPara,Condition condition); 34 | public List nearSphere(T entity,NearPara nearPara,Condition condition); 35 | public List geoWithinCenter(T entity,CenterPara centerPara,Condition condition); 36 | public List geoWithinCenterSphere(T entity,CenterPara centerPara,Condition condition); 37 | public List geoWithinBox(T entity,BoxPara boxPara,Condition condition); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/mongodb/MongodbRawSql.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2023 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.mongodb; 19 | 20 | import java.util.List; 21 | import java.util.Map; 22 | 23 | import org.teasoft.bee.osql.CommOperate; 24 | 25 | /** 26 | * Interface support Mongo Shell Query Language(Shell command). 27 | * @author Kingstar 28 | * @since V2.1 29 | */ 30 | public interface MongodbRawSql extends CommOperate { 31 | 32 | /** 33 | * Select document(s)/record(s) via find/findOne command. 34 | * @param sql find command. 35 | * @param returnTypeClass its type same as list element. 36 | * @return List which element type is same as returnTypeClass. 37 | */ 38 | public List select(String sql, Class returnTypeClass); 39 | 40 | /** 41 | * Select document(s)/record(s) via find/findOne command and return json format result. 42 | * @param sql find command. 43 | * @return Json format result. 44 | */ 45 | public String selectJson(String sql); 46 | 47 | /** 48 | * Select document(s)/record(s) via find/findOne command and return list structure data whose element is Map. 49 | * @param sql find command. 50 | * @return the multi-line record of List> structure. 51 | */ 52 | public List> selectMapList(String sql); 53 | 54 | // public String selectFun(String sql); 55 | 56 | 57 | /** 58 | * Modify database document(s)/record(s) with update, insert or delete type command. 59 | * @param sql find command. 60 | * @return the number of affected successfully document(s)/record(s). 61 | */ 62 | public int modify(String sql); 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/mongodb/NearPara.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2023 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.mongodb; 19 | 20 | import org.teasoft.bee.osql.exception.BeeIllegalBusinessException; 21 | 22 | /** 23 | * Near parameter struct for Mongodb Geo. 24 | * @author Kingstar 25 | * @since 2.1 26 | */ 27 | public class NearPara { 28 | 29 | private String geoFieldName; 30 | private double x; 31 | private double y; 32 | private Double maxDistance; 33 | private Double minDistance; 34 | 35 | public NearPara() {} 36 | 37 | public NearPara(String geoFieldName, double x, double y, Double maxDistance, 38 | Double minDistance){ 39 | 40 | this.geoFieldName = geoFieldName; 41 | this.x = x; 42 | this.y = y; 43 | this.maxDistance = maxDistance; 44 | this.minDistance = minDistance; 45 | 46 | if (maxDistance < minDistance) throw new BeeIllegalBusinessException("The maximum value must not be less than the minimum value!"); 47 | } 48 | 49 | public String getGeoFieldName() { 50 | return geoFieldName; 51 | } 52 | 53 | public void setGeoFieldName(String geoFieldName) { 54 | this.geoFieldName = geoFieldName; 55 | } 56 | 57 | public double getX() { 58 | return x; 59 | } 60 | 61 | public void setX(double x) { 62 | this.x = x; 63 | } 64 | 65 | public double getY() { 66 | return y; 67 | } 68 | 69 | public void setY(double y) { 70 | this.y = y; 71 | } 72 | 73 | public Double getMaxDistance() { 74 | return maxDistance; 75 | } 76 | 77 | public void setMaxDistance(Double maxDistance) { 78 | this.maxDistance = maxDistance; 79 | } 80 | 81 | public Double getMinDistance() { 82 | return minDistance; 83 | } 84 | 85 | public void setMinDistance(Double minDistance) { 86 | this.minDistance = minDistance; 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/mvc/service/ObjSQLRichService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.mvc.service; 19 | 20 | import org.teasoft.bee.osql.api.SuidRich; 21 | 22 | /** 23 | * Default common object rich SQLService. 24 | * @author Kingstar 25 | * @since 1.0 26 | */ 27 | public interface ObjSQLRichService extends SuidRich { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/mvc/service/ObjSQLService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.mvc.service; 19 | 20 | import org.teasoft.bee.osql.api.Suid; 21 | 22 | /** 23 | * Default common object SQLService. 24 | * @author Kingstar 25 | * @since 1.0 26 | */ 27 | public interface ObjSQLService extends Suid { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/BeeAbstractFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql; 19 | 20 | import java.util.Map; 21 | 22 | import javax.sql.DataSource; 23 | 24 | import org.teasoft.bee.osql.transaction.Transaction; 25 | 26 | /** 27 | * An abstract super class about DataSource and Transaction. 28 | * @author Kingstar 29 | * @since 1.0 30 | */ 31 | public abstract class BeeAbstractFactory { 32 | 33 | private DataSource dataSource; 34 | private Transaction transaction; 35 | 36 | // v1.8 37 | private Map dataSourceMap; 38 | 39 | public DataSource getDataSource() { 40 | return dataSource; 41 | } 42 | 43 | /** 44 | * set dataSource. if is reset, need tell the context setConfigRefresh 45 | * @param dataSource dataSource 46 | */ 47 | public void setDataSource(DataSource dataSource) { 48 | this.dataSource = dataSource; 49 | } 50 | 51 | public Transaction getTransaction() { 52 | return transaction; 53 | } 54 | 55 | public void setTransaction(Transaction transaction) { 56 | this.transaction = transaction; 57 | } 58 | 59 | public Map getDataSourceMap() { 60 | return dataSourceMap; 61 | } 62 | 63 | public void setDataSourceMap(Map dataSourceMap) { 64 | this.dataSourceMap = dataSourceMap; 65 | parseDbNameByDsMap(); 66 | } 67 | 68 | protected abstract void parseDbNameByDsMap(); 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/BeeExtCache.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql; 19 | 20 | /** 21 | * Ext Cache interface. 22 | * @author Kingstar 23 | * @since 1.11 24 | */ 25 | public interface BeeExtCache extends Cache { 26 | 27 | /** 28 | * Get the cache result by key(sql). 29 | * @param key cache key,normally it is sql. 30 | * @return result record 31 | */ 32 | public Object getInExtCache(String key); 33 | 34 | /** 35 | * Put the result in the cache identify with key(sql). 36 | * @param key cache key,normally it is sql. 37 | * @param result result record 38 | */ 39 | public void addInExtCache(String key, Object result); 40 | 41 | /** 42 | * Clear the cache result of related table by key(sql). 43 | * @param key cache key,normally it is sql. 44 | */ 45 | public void clearInExtCache(String key); 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/BeeSQLException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2020 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql; 19 | 20 | /** 21 | * Bee's SQL super exception class. 22 | * @author Kingstar 23 | * @since 1.4 24 | */ 25 | public class BeeSQLException extends BeeException { 26 | static final long serialVersionUID = -875516993124222222L; 27 | 28 | private String SQLState; 29 | private int vendorCode; 30 | 31 | public BeeSQLException() { 32 | super(); 33 | } 34 | 35 | public BeeSQLException(String message) { 36 | super(message); 37 | } 38 | 39 | public BeeSQLException(String message, Throwable cause) { 40 | super(message, cause); 41 | } 42 | 43 | public BeeSQLException(Throwable cause) { 44 | super(cause); 45 | } 46 | 47 | protected BeeSQLException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 48 | super(message, cause, enableSuppression, writableStackTrace); 49 | } 50 | 51 | public BeeSQLException(String reason, String sqlState, int vendorCode, Throwable cause) { 52 | super(reason, cause); 53 | this.SQLState = sqlState; 54 | this.vendorCode = vendorCode; 55 | } 56 | 57 | /** 58 | * Retrieves the SQLState for this BeeSQLException object. 59 | * 60 | * @return the SQLState value 61 | */ 62 | public String getSQLState() { 63 | return (SQLState); 64 | } 65 | 66 | /** 67 | * Retrieves the vendor-specific exception code 68 | * for this BeeSQLException object. 69 | * 70 | * @return the vendor's error code 71 | */ 72 | public int getErrorCode() { 73 | return (vendorCode); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/BeeVersion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql; 19 | 20 | /** 21 | * Bee Version. 22 | * @author Kingstar 23 | * @since 1.11 24 | */ 25 | public final class BeeVersion { 26 | 27 | public static final String version = "2.5.2"; 28 | public static final String buildId = version + ".2"; 29 | 30 | private BeeVersion() {} 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/Cache.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2019 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql; 19 | 20 | import java.io.Serializable; 21 | 22 | /** 23 | * Cache interface. 24 | *
Gen the key via sql string, then operate the cache by the key. 25 | * @author Kingstar 26 | * @since 1.4 27 | */ 28 | public interface Cache extends Serializable { 29 | 30 | /** 31 | * Get the cache result by sql. 32 | * @param sql sql for select 33 | * @return cache result set. 34 | */ 35 | public Object get(String sql); 36 | 37 | /** 38 | * Put the result in the cache identify with sql. 39 | * @param sql sql for select 40 | * @param result result of select 41 | */ 42 | public void add(String sql, Object result); 43 | 44 | /** 45 | * Clear the cache result of related table by sql. 46 | * @param sql sql for modify 47 | */ 48 | public void clear(String sql); 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/CommOperate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql; 19 | 20 | import org.teasoft.bee.osql.interccept.InterceptorChain; 21 | 22 | /** 23 | * Common operate interface about Suid. 24 | * @author Kingstar 25 | * @since 1.11 26 | */ 27 | public interface CommOperate { 28 | 29 | /** 30 | * Set the dataSource for current instance. If use the default settings that are not required. 31 | * Set dataSource name (corresponding data source must be defined). 32 | * Only effective once. 33 | * @param dsName dataSource name 34 | */ 35 | public void setDataSourceName(String dsName); 36 | 37 | /** 38 | * get DataSource name which set for current instance. 39 | * @return DataSource name 40 | */ 41 | public String getDataSourceName(); 42 | 43 | /** 44 | * Get the Interceptor chain, which can be used for a generated object set a specific interceptor. 45 | * @return InterceptorChain 46 | */ 47 | public InterceptorChain getInterceptorChain(); 48 | 49 | /** 50 | * Set the NameTranslate for current instance. 51 | * Since 2.1 only effective once. 52 | * If use the default settings that are not required. 53 | * @param nameTranslate nameTranslate 54 | */ 55 | public void setNameTranslateOneTime(NameTranslate nameTranslate); 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/ConditionAssistant.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2020 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql; 19 | 20 | import java.util.List; 21 | import java.util.Map; 22 | import java.util.Set; 23 | 24 | /** 25 | * Assistant of Condition. 26 | * @author Kingstar 27 | * @since 1.6 28 | */ 29 | public interface ConditionAssistant { 30 | 31 | /** 32 | * If the field use in Condition,it would not be processed again in default. 33 | * @return Returns fields collection for where condition expression. 34 | */ 35 | public Set getWhereFields(); 36 | 37 | public void setSuidType(SuidType suidType); 38 | 39 | /** 40 | * 41 | * @return return IncludeType 42 | * @since 1.7 43 | */ 44 | public IncludeType getIncludeType(); 45 | 46 | /** 47 | * return the fields use in method of setAdd and setMultiply. 48 | * @return set of fields 49 | * @since 1.7.2 50 | */ 51 | public Set getUpdatefields(); 52 | 53 | public String[] getSelectField(); 54 | 55 | public Boolean getForUpdate(); 56 | 57 | /** 58 | * get the map of OrderBy 59 | * @return the map of OrderBy 60 | * @since 2.0 61 | */ 62 | public Map getOrderBy(); 63 | 64 | /** 65 | * the Boolean value whether has GroupBy 66 | * @return the Boolean value whether has GroupBy 67 | * @since 2.0 68 | */ 69 | public Boolean hasGroupBy(); // for mongodb 70 | 71 | /** 72 | * get GroupByfields 73 | * @return the list of GroupByfields 74 | * @since 2.0 75 | */ 76 | public List getGroupByFields(); // for mongodb 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/DatabaseConst.java: -------------------------------------------------------------------------------- 1 | package org.teasoft.bee.osql; 2 | 3 | /** 4 | * Database Name Const. 5 | * @author Kingstar 6 | * @since 1.0 7 | */ 8 | public final class DatabaseConst { 9 | 10 | private DatabaseConst() {} 11 | 12 | public static final String MYSQL = "MySQL"; 13 | public static final String MariaDB = "MariaDB"; 14 | public static final String ORACLE = "Oracle"; 15 | public static final String SQLSERVER = "Microsoft SQL Server"; 16 | public static final String MsAccess = "Microsoft Access"; // Microsoft Access 17 | public static final String AzureSQL = SQLSERVER; 18 | 19 | public static final String H2 = "H2"; 20 | public static final String SQLite = "SQLite"; 21 | // public static final String AndroidSQLite = "AndroidSQLite"; 22 | // public static final String HarmonySQLite = "HarmonySQLite"; 23 | public static final String PostgreSQL = "PostgreSQL"; 24 | 25 | public static final String Cubrid = "Cubrid"; 26 | public static final String DB2400 = "DB2 UDB for AS/400"; 27 | public static final String DB2 = "DB2"; // todo 28 | public static final String Derby = "Apache Derby"; 29 | public static final String Firebird = "Firebird"; 30 | public static final String FrontBase = "FrontBase"; 31 | 32 | public static final String HSQL = "HSQL Database Engine"; 33 | public static final String HSQLDB = "HSQL Database"; 34 | public static final String Informix = "Informix Dynamic Server"; 35 | public static final String Ingres = "Ingres"; 36 | public static final String JDataStore = "JDataStore"; 37 | public static final String Mckoi = "Mckoi"; 38 | public static final String MimerSQL = "MimerSQL"; 39 | public static final String Pointbase = "Pointbase"; 40 | 41 | public static final String SAPDB = "SAPDB"; 42 | public static final String Sybase = "Sybase SQL Server"; 43 | public static final String Teradata = "Teradata"; 44 | public static final String TimesTen = "TimesTen"; 45 | 46 | public static final String DM = "DM DBMS"; 47 | public static final String Kingbase = "KingbaseES"; 48 | public static final String GaussDB = "GaussDB"; 49 | 50 | public static final String OceanBase = "OceanBase"; 51 | 52 | // NoSql 53 | public static final String Cassandra = "Cassandra"; 54 | public static final String Hbase = "Hbase"; 55 | public static final String Hypertable = "Hypertable"; 56 | public static final String DynamoDB = "DynamoDB"; 57 | 58 | public static final String MongoDB = "MongoDB"; 59 | public static final String CouchDB = "CouchDB"; 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/FunctionType.java: -------------------------------------------------------------------------------- 1 | package org.teasoft.bee.osql; 2 | 3 | /** 4 | * Function type of SQL. 5 | * @author Kingstar 6 | * @since 1.0 7 | */ 8 | public enum FunctionType { 9 | 10 | MAX("max"), MIN("min"), SUM("sum"), AVG("avg"), COUNT("count"); 11 | 12 | String name; 13 | 14 | FunctionType(String name) { 15 | this.name = name; 16 | } 17 | 18 | public String getName() { 19 | return name; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/IncludeType.java: -------------------------------------------------------------------------------- 1 | package org.teasoft.bee.osql; 2 | 3 | /** 4 | * Include type about Null and empty string. 5 | * @author Kingstar 6 | * @since 1.0 7 | */ 8 | public enum IncludeType { 9 | 10 | /** 11 | * exclude: NULL and "" 12 | */ 13 | EXCLUDE_BOTH(-1), // v1.9 14 | 15 | /** 16 | * include: NULL 17 | */ 18 | INCLUDE_NULL(0), 19 | /** 20 | * include: "" 21 | */ 22 | INCLUDE_EMPTY(1), 23 | 24 | /** 25 | * include: NULL and "" 26 | */ 27 | INCLUDE_BOTH(2), 28 | /** 29 | * exclude: NULL , "" and " " 30 | */ 31 | EXCLUDE_THREE(-3); 32 | 33 | private final int value; 34 | 35 | private IncludeType(int value) { 36 | this.value = value; 37 | } 38 | 39 | public int getValue() { 40 | return this.value; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/MapSqlKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql; 19 | 20 | /** 21 | * MapSql keyword for the corresponding SQL function of MapSuid. 22 | * @author Kingstar 23 | * @since 1.9 24 | */ 25 | public enum MapSqlKey { 26 | 27 | /** 28 | * Declare the table to be operated on. 29 | */ 30 | Table("Table"), 31 | 32 | /** 33 | * In the method insertAndReturnId(MapSql mapSql) of MapSuid, it is used when the primary key name is not 'id'. 34 | * @since 1.11 35 | */ 36 | PrimaryKey("PrimaryKey"), 37 | 38 | /** 39 | * Declare the select fields,if more than one,separate with comma. 40 | */ 41 | SelectColumns("SelectColumns"), 42 | 43 | /** 44 | * It corresponds to the group by of SQL. 45 | */ 46 | GroupBy("GroupBy"), 47 | 48 | /** 49 | * It corresponds to the having of SQL. 50 | */ 51 | Having("Having"), 52 | 53 | /** 54 | * It corresponds to the order by of SQL. 55 | */ 56 | OrderBy("OrderBy") 57 | 58 | ; 59 | 60 | String name; 61 | 62 | MapSqlKey(String name) { 63 | this.name = name; 64 | } 65 | 66 | public String getName() { 67 | return name; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/MapSqlSetting.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql; 19 | 20 | /** 21 | * MapSql configuration information for MapSuid. 22 | * @author Kingstar 23 | * @since 1.9 24 | */ 25 | public enum MapSqlSetting { 26 | 27 | /** 28 | * Is naming transfer. value is 'true' or 'false',default is 'false' 29 | * if true, will transfer by the rule (eg: bee.properties). if false,do not transfer. 30 | */ 31 | IsNamingTransfer("IsNamingTransfer"), 32 | 33 | /** 34 | * include Null.value is 'true' or 'false',default is 'false' 35 | */ 36 | IsIncludeNull("IsIncludeNull"), 37 | 38 | /** 39 | * include empty string.value is 'true' or 'false',default is 'false' 40 | * @since V1.11 41 | */ 42 | IsIncludeEmptyString("IsIncludeEmptyString"), 43 | 44 | /** 45 | * "true" and "false" String transfer to Boolean Type. 46 | * It will be transfer by default. 47 | */ 48 | IsTransferTrueFalseStringToBooleanType("IsTransferTrueFalseStringToBooleanType"), 49 | 50 | /** 51 | * if IsGenId is true, will override the old value. 52 | */ 53 | IsGenId("IsGenId"), 54 | 55 | /** 56 | * id type default is Long,if use Integer need setting. 57 | */ 58 | IsUseIntegerId("IsUseIntegerId"); 59 | 60 | String name; 61 | 62 | MapSqlSetting(String name) { 63 | this.name = name; 64 | } 65 | 66 | public String getName() { 67 | return name; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/MoreObjToSQL.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2020 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql; 19 | 20 | import org.teasoft.bee.osql.api.Condition; 21 | 22 | /** 23 | * Select of More Objects to SQL. 24 | * @author Kingstar 25 | * @since 1.7 26 | */ 27 | public interface MoreObjToSQL { 28 | 29 | /** 30 | * Convert to SQL statement according to entity. 31 | * @param entity table's entity(do not allow null). 32 | * @return the sql String. 33 | */ 34 | public String toSelectSQL(T entity); 35 | 36 | /** 37 | * Convert to SQL statement according to entity and paging parameters. 38 | * @param entity table's entity(do not allow null). 39 | * @param start 40 | * @param size 41 | * @return the sql String. 42 | */ 43 | public String toSelectSQL(T entity, int start, int size); 44 | 45 | /** 46 | * Convert to SQL statement according to entity and condition. 47 | * @param entity table's entity(do not allow null). 48 | * @param condition if the field is not null or empty, it will be translate to field=value.Other can define with condition. 49 | * @return the sql String. 50 | */ 51 | public String toSelectSQL(T entity, Condition condition); 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/NameTranslate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2019 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql; 19 | 20 | /** 21 | * Table name and entity name, column name and field name are transferred to each other. 22 | * table name<-->entity name, coloumn name<-->field name. 23 | * @author Kingstar 24 | * @since 1.5 25 | */ 26 | public interface NameTranslate { 27 | 28 | /** 29 | * Entity name to table name. 30 | * @param entityName 31 | * @return table name. 32 | */ 33 | public String toTableName(String entityName); 34 | 35 | /** 36 | * Field name to column name. 37 | * @param fieldName field name in Java entity. 38 | * @return column name. 39 | */ 40 | public String toColumnName(String fieldName); 41 | 42 | /** 43 | * Table name to entity name. 44 | * @param tableName 45 | * @return entity name(Javabean name). 46 | */ 47 | public String toEntityName(String tableName); 48 | 49 | /** 50 | * Column name to field name. 51 | * @param columnName DB table's column name. 52 | * @return Javabean's field name. 53 | */ 54 | public String toFieldName(String columnName); 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/ObjSQLException.java: -------------------------------------------------------------------------------- 1 | package org.teasoft.bee.osql; 2 | 3 | /** 4 | * Bee's Object SQL super exception class. 5 | * @author Kingstar 6 | * @since 1.0 7 | */ 8 | public class ObjSQLException extends BeeException { 9 | static final long serialVersionUID = -875516993124211111L; 10 | 11 | public ObjSQLException() { 12 | super(); 13 | } 14 | 15 | public ObjSQLException(String message) { 16 | super(message); 17 | } 18 | 19 | public ObjSQLException(String message, Throwable cause) { 20 | super(message, cause); 21 | } 22 | 23 | public ObjSQLException(Throwable cause) { 24 | super(cause); 25 | } 26 | 27 | protected ObjSQLException(String message, Throwable cause, 28 | boolean enableSuppression, boolean writableStackTrace) { 29 | super(message, cause, enableSuppression, writableStackTrace); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/ObjSQLIllegalSQLStringException.java: -------------------------------------------------------------------------------- 1 | package org.teasoft.bee.osql; 2 | 3 | /** 4 | * Object SQL illegal SQL string exception. 5 | * @author Kingstar 6 | * @since 1.0 7 | */ 8 | public class ObjSQLIllegalSQLStringException extends BeeException { 9 | static final long serialVersionUID = -875516993124211122L; 10 | public ObjSQLIllegalSQLStringException() { 11 | super(); 12 | } 13 | 14 | public ObjSQLIllegalSQLStringException(String message) { 15 | super(message); 16 | } 17 | 18 | public ObjSQLIllegalSQLStringException(String message, Throwable cause) { 19 | super(message, cause); 20 | } 21 | 22 | public ObjSQLIllegalSQLStringException(Throwable cause) { 23 | super(cause); 24 | } 25 | 26 | protected ObjSQLIllegalSQLStringException(String message, Throwable cause, 27 | boolean enableSuppression, boolean writableStackTrace) { 28 | super(message, cause, enableSuppression, writableStackTrace); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/ObjToSQL.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql; 19 | 20 | import org.teasoft.bee.osql.api.Condition; 21 | 22 | /** 23 | * Object to SQL string for Suid.
24 | * Object to SQL string for Suid (select,update,insert,delete), 25 | * entity must not be null. 26 | * @author Kingstar 27 | * @since 1.0 28 | */ 29 | public interface ObjToSQL { 30 | 31 | /** 32 | * Convert to select SQL statement according to entity. 33 | * @param entity table's entity(do not allow null). 34 | * @return the sql string. 35 | */ 36 | public String toSelectSQL(T entity); 37 | 38 | /** 39 | * Convert to update SQL statement according to entity. 40 | * @param entity table's entity(do not allow null). 41 | * @return the sql string. 42 | */ 43 | public String toUpdateSQL(T entity); 44 | 45 | /** 46 | * Convert to insert SQL statement according to entity. 47 | * @param entity table's entity(do not allow null). 48 | * @return the sql string. 49 | */ 50 | public String toInsertSQL(T entity); 51 | 52 | /** 53 | * Convert to delete SQL statement according to entity. 54 | * @param entity table's entity(do not allow null). 55 | * @return the sql string. 56 | */ 57 | public String toDeleteSQL(T entity); 58 | 59 | /** 60 | * Convert to select SQL statement according to entity and condition. 61 | * @param entity table's entity(do not allow null). 62 | * @param condition instance of Condition. 63 | * @return the sql string. 64 | * @since 1.6 65 | */ 66 | public String toSelectSQL(T entity, Condition condition); 67 | 68 | /** 69 | * Convert to delete SQL statement according to entity and condition 70 | * @param entity table's entity(do not allow null). 71 | * @param condition instance of Condition. 72 | * @return the sql string. 73 | * @since 1.7.2 74 | */ 75 | public String toDeleteSQL(T entity, Condition condition); 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/OneMethod.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * The license,see the LICENSE file. 5 | */ 6 | 7 | package org.teasoft.bee.osql; 8 | 9 | /** 10 | * @author Kingstar 11 | * @since 2.5.2 12 | */ 13 | public interface OneMethod { 14 | 15 | public T doOneMethod(); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/OrderType.java: -------------------------------------------------------------------------------- 1 | package org.teasoft.bee.osql; 2 | 3 | /** 4 | * SQL's Order type(asc,desc). 5 | * @author Kingstar 6 | * @since 1.0 7 | */ 8 | public enum OrderType { 9 | 10 | /** 11 | * Corresponding to ASC of SQL 12 | */ 13 | ASC("asc"), 14 | 15 | /** 16 | * Corresponding to desc of SQL 17 | */ 18 | DESC("desc"); 19 | 20 | String name; 21 | 22 | OrderType(String name) { 23 | this.name = name; 24 | } 25 | 26 | /** 27 | * return type of order. 28 | * @return type of order. 29 | */ 30 | public String getName() { 31 | return name; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/Properties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql; 19 | 20 | import java.util.Set; 21 | 22 | /** 23 | * Properties interface. 24 | * @author Kingstar 25 | * @since 1.11 26 | */ 27 | public interface Properties { 28 | 29 | public String getProp(String key); 30 | 31 | public String getPropText(String key); 32 | 33 | public Set getKeys(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/Registry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql; 19 | 20 | /** 21 | * Registry interface. 22 | * @author Kingstar 23 | * @since 1.11 24 | */ 25 | public interface Registry { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/ResultAssembler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-2024 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql; 19 | 20 | import java.sql.ResultSet; 21 | import java.sql.SQLException; 22 | 23 | /** 24 | * ResultSet Assembler for select type. 25 | * @author Kingstar 26 | * @since 2.4.0 27 | */ 28 | public interface ResultAssembler { 29 | 30 | /** 31 | * 32 | * @param rs ResultSet object 33 | * @param clazz entity class type. 34 | * @return entity object 35 | * @throws SQLException 36 | * @throws IllegalAccessException 37 | * @throws InstantiationException 38 | */ 39 | public T rowToEntity(ResultSet rs, Class clazz) 40 | throws SQLException, IllegalAccessException, InstantiationException; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/ResultAssemblerRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-2024 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql; 19 | 20 | import java.util.HashMap; 21 | import java.util.Map; 22 | 23 | /** 24 | * ResultSet Assembler Registry. 25 | * @author Kingstar 26 | * @since 2.4.0 27 | */ 28 | public class ResultAssemblerRegistry implements Registry { 29 | 30 | private static final Map, ResultAssembler> assemblerMap = new HashMap<>(); 31 | 32 | public static void register(Class c, ResultAssembler assembler) { 33 | assemblerMap.put(c, assembler); 34 | } 35 | 36 | @SuppressWarnings("unchecked") 37 | public static ResultAssembler getResultAssembler(Class c) { 38 | return (ResultAssembler) assemblerMap.get(c); 39 | } 40 | 41 | public static boolean hadReg(Class c) { 42 | return ResultAssemblerRegistry.getResultAssembler(c) != null; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/Serializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql; 19 | 20 | import java.io.IOException; 21 | 22 | /** 23 | * Serializer. 24 | * @author Kingstar 25 | * @since 1.11 26 | */ 27 | public interface Serializer { 28 | 29 | public byte[] serialize(Object obj) throws IOException; 30 | 31 | public Object unserialize(byte[] bytes) throws IOException; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/SqlKeyWord.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2020 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql; 19 | 20 | /** 21 | * SQL KeyWord. 22 | * @author Kingstar 23 | * @since 1.8.99 24 | */ 25 | public interface SqlKeyWord { 26 | 27 | String select(); 28 | String as(); 29 | String from(); 30 | String where(); 31 | 32 | String insert(); 33 | String replace(); 34 | String into(); 35 | String values(); 36 | String and(); 37 | String or(); 38 | /** 39 | * add "!" 40 | * @return "!" is mean "not" 41 | * since 2.1.10 42 | */ 43 | String not(); 44 | 45 | String Null(); 46 | String isNull(); 47 | String isNotNull(); 48 | 49 | String update(); 50 | String set(); 51 | String delete(); 52 | 53 | String orderBy(); 54 | String count(); 55 | String asc(); 56 | 57 | String on(); 58 | String forUpdate(); 59 | String limit(); 60 | String offset(); 61 | String top(); 62 | 63 | String groupBy(); 64 | String having(); 65 | String between(); 66 | String notBetween(); 67 | 68 | String space(); 69 | 70 | String distinct(); 71 | String join(); 72 | String innerJoin(); 73 | String leftJoin(); 74 | String rightJoin(); 75 | String in(); 76 | String notIn(); 77 | String exists(); 78 | String notExists(); 79 | 80 | String union();//2.0 81 | String unionAll();//2.0 82 | 83 | //2.4.0 84 | String truncate(); 85 | String table(); 86 | String drop(); 87 | String If(); 88 | String to_date(); 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/SuidType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2020 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql; 19 | 20 | /** 21 | * Database Suid(Select,Update,Insert,Delete) type. 22 | * @author Kingstar 23 | * @since 1.4 24 | */ 25 | public enum SuidType { 26 | 27 | /** 28 | * Select operation corresponding to SQL 29 | */ 30 | SELECT("SELECT"), 31 | 32 | /** 33 | * UPDATE operation corresponding to SQL 34 | */ 35 | UPDATE("UPDATE"), 36 | 37 | /** 38 | * INSERT operation corresponding to SQL 39 | */ 40 | INSERT("INSERT"), 41 | 42 | /** 43 | * DELETE operation corresponding to SQL 44 | */ 45 | DELETE("DELETE"), 46 | /** 47 | * UPDATE,INSERT,DELETE operation corresponding to SQL 48 | */ 49 | MODIFY("MODIFY"), 50 | 51 | /** 52 | * SELECT,UPDATE,INSERT,DELETE 53 | * @since 1.11 54 | */ 55 | SUID("SUID"), 56 | 57 | /** 58 | * @since 2.0 59 | */ 60 | DDL("DDL"); 61 | 62 | private String type; 63 | 64 | SuidType(String type) { 65 | this.type = type; 66 | } 67 | 68 | public String getType() { 69 | return type; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/TO_DATE.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql; 19 | 20 | import java.io.Serializable; 21 | 22 | /** 23 | * can use TO_DATE in : 24 | *
Condition op(String field, Op op, Object value) 25 | *
for Oracle. 26 | *
eg:condition.op("mydatetime", Op.ge, new TO_DATE("2024-07-08", "YYYY-MM-DD")); 27 | *
-> 28 | *
where mydatetime>=TO_DATE('2024-07-08', 'YYYY-MM-DD') ; 29 | *
In general, this interface is only used for Oracle. 30 | * @author Kingstar 31 | * @since 2.4.0 32 | */ 33 | public class TO_DATE implements Serializable { 34 | 35 | private static final long serialVersionUID = 1596710362290L; 36 | 37 | private String datetimeValue; 38 | private String formatter; 39 | 40 | public TO_DATE() {} 41 | 42 | public TO_DATE(String datetimeValue, String formatter) { 43 | this.datetimeValue = datetimeValue; 44 | this.formatter = formatter; 45 | } 46 | 47 | public String getDatetimeValue() { 48 | return datetimeValue; 49 | } 50 | 51 | public void setDatetimeValue(String datetimeValue) { 52 | this.datetimeValue = datetimeValue; 53 | } 54 | 55 | public String getFormatter() { 56 | return formatter; 57 | } 58 | 59 | public void setFormatter(String formatter) { 60 | this.formatter = formatter; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/AbstractDictI18nDefaultHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import java.lang.reflect.Field; 21 | import java.util.List; 22 | 23 | /** 24 | * Abstract DictI18n Default Handler. 25 | * @author Kingstar 26 | * @since 1.11 27 | */ 28 | public abstract class AbstractDictI18nDefaultHandler implements BeforeReturnAnnotationHandler { 29 | 30 | @Override 31 | @SuppressWarnings("rawtypes") 32 | public void process(Field field, List list) { 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/AnnotationHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import java.util.Map; 21 | 22 | /** 23 | * Annotation Handler Interface. 24 | * @author Kingstar 25 | * @since 1.11 26 | */ 27 | public interface AnnotationHandler { 28 | 29 | public String process(); 30 | 31 | public String process(String s); 32 | 33 | @SuppressWarnings("rawtypes") 34 | public String process(Map para); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/AutoSetString.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | import org.teasoft.bee.osql.SuidType; 26 | 27 | /** 28 | * Automatically setting the fields remark by AutoSetValue annotation. 29 | *
The setting value is provided by the class specified by the handler. 30 | *
The field type needs to be java.lang.String. 31 | * @author Kingstar 32 | * @since 1.11 33 | */ 34 | @Target(ElementType.FIELD) 35 | @Retention(RetentionPolicy.RUNTIME) 36 | public @interface AutoSetString { 37 | boolean override() default false; 38 | 39 | SuidType suidType(); 40 | 41 | Class handler(); 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/BeforeReturnAnnotationHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import java.lang.reflect.Field; 21 | import java.util.List; 22 | 23 | /** 24 | * Annotation Handler Interface trigger on before return. 25 | * @author Kingstar 26 | * @since 1.11 27 | */ 28 | public interface BeforeReturnAnnotationHandler { 29 | 30 | /** 31 | * 32 | * @param field Field with corresponding annotation 33 | * @param list List of annotations to be processed 34 | */ 35 | @SuppressWarnings("rawtypes") 36 | public void process(Field field,List list); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/Column.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Table column names and Javabean field names mapping annotation. 27 | * 28 | * Before 2.0, to use @column, open the openDefineColumn configuration and realize the mapping function. 29 | * Since 2.1, it will be open by default. If not used, in order to improve efficiency, it can be manually configured to be closed. 30 | *


31 | *

Where will detect this annotation: 32 | *

Object oriented way: Suid,SuidRich,MoreTable will detect. 33 | *

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

Where will not detect this annotation: 35 | *

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

Mapsuid will not detect 37 | *

JustFetch annotated fields should not be annotated with Column. 38 | * @author Kingstar 39 | * @since 1.11 40 | */ 41 | @Target(ElementType.FIELD) 42 | @Retention(RetentionPolicy.RUNTIME) 43 | public @interface Column { 44 | String value(); 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/ColumnHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | /** 21 | * Column Annotation handler interface. 22 | * @author Kingstar 23 | * @since 1.11 24 | */ 25 | @SuppressWarnings("rawtypes") 26 | public interface ColumnHandler { 27 | 28 | /** 29 | * translate to Column Name. 30 | * @param fieldName field name 31 | * @param entityClass entity class 32 | * @return column name. 33 | */ 34 | public String toColumnName(String fieldName, Class entityClass); 35 | 36 | 37 | /** 38 | * translate to Field Name. 39 | * @param columnName column name 40 | * @param entityClass entity class 41 | * @return field name. 42 | */ 43 | public String toFieldName(String columnName, Class entityClass); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/Createtime.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Generate creation time(current time) automatically when insert records. 27 | * @author Kingstar 28 | * @since 1.11 29 | */ 30 | @Target(ElementType.FIELD) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | public @interface Createtime { 33 | String formatter() default ""; 34 | boolean override() default false; 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/Datetime.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | import org.teasoft.bee.osql.SuidType; 26 | 27 | /** 28 | * Datetime annotation 29 | * @author Kingstar 30 | * @since 1.11 31 | */ 32 | @Target(ElementType.FIELD) 33 | @Retention(RetentionPolicy.RUNTIME) 34 | public @interface Datetime { 35 | 36 | String formatter() default ""; 37 | 38 | boolean override() default false; 39 | 40 | SuidType suidType(); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/Desensitize.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Starting from the specified position, change the specified size of characters to mask characters. 27 | *
eg: 28 | *
\@Desensitize(start=5, size=2, mask="*") 29 | *
private String sequence; 30 | *
sequence in the database is: 0123456789 31 | *
after process: 32 | *
sequence=01234**789 33 | *
V2.0 34 | *
\@Desensitize(start=0, size=-1, mask="*") //replace all 35 | *
\@Desensitize(start=2, size=-1, mask="*") //replace from 2 to end 36 | * @author Kingstar 37 | * @since 1.11 38 | */ 39 | @Target(ElementType.FIELD) 40 | @Retention(RetentionPolicy.RUNTIME) 41 | public @interface Desensitize { 42 | /** 43 | * Start position (starting from 0) 44 | * @return start position 45 | */ 46 | int start(); 47 | 48 | /** 49 | * the number of characters need to replace; 50 | * if it is - 1, replace it until the end(V2.0). 51 | * @return the number of characters need to replace 52 | */ 53 | int size(); 54 | 55 | /** 56 | * Mask used 57 | * @return mask code 58 | */ 59 | String mask(); 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/Dict.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Dictionary conversion annotation is used to filter and process the returned data 27 | *
of query according to rules. If there is no mapping, it will not be replaced. 28 | *
Version 1.11, general processing implementation is not provided yet 29 |

30 |

data in Databsee: 31 |

flag=null 32 |

flag=1 33 |

flag=0 34 |

flag= 35 |

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

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

private String flag; 38 |

after process: 39 |

flag=? 40 |

flag=Yes 41 |

flag=No 42 |

flag=empty 43 | 44 | * @author Kingstar 45 | * @since 1.11 46 | */ 47 | @Target(ElementType.FIELD) 48 | @Retention(RetentionPolicy.RUNTIME) 49 | public @interface Dict { 50 | 51 | String map() default ""; 52 | 53 | /** 54 | * The value of the replacement when the field value is null. 55 | * @return value replace for null 56 | */ 57 | String nullToValue() default "@#placeholderStr(default do not process)"; 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/DictI18n.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Support international multi language dictionary conversion annotation, 27 | * which is generally used for global unified setting. 28 | *
It is used to filter and process the returned data of query according to rules. 29 | * @author Kingstar 30 | * @since 1.11 31 | */ 32 | @Target(ElementType.FIELD) 33 | @Retention(RetentionPolicy.RUNTIME) 34 | public @interface DictI18n { 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/DsTabHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import org.teasoft.bee.sharding.DsTabStruct; 21 | import org.teasoft.bee.sharding.ShardingSimpleStruct; 22 | 23 | /** 24 | * DataSource and Table Handler 25 | * @author Kingstar 26 | * @since 1.11 27 | */ 28 | public interface DsTabHandler { 29 | 30 | public DsTabStruct process(ShardingSimpleStruct shardingSimpleStruct); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/Entity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2020 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | 19 | package org.teasoft.bee.osql.annotation; 20 | 21 | import java.lang.annotation.ElementType; 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.RetentionPolicy; 24 | import java.lang.annotation.Target; 25 | 26 | /** 27 | * Dynamic named for Javabean. 28 | * @author Kingstar 29 | * @since 1.8 30 | */ 31 | @Target(ElementType.TYPE) 32 | @Retention(RetentionPolicy.RUNTIME) 33 | public @interface Entity { 34 | String value(); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/FK.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2023 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Foreign Key annotation,use for UPDATE,INSERT,DELETE. 27 | * @author Kingstar 28 | * @since 2.1.8 29 | */ 30 | @Target(ElementType.FIELD) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | public @interface FK { 33 | 34 | /** 35 | * foreign key 36 | * @return foreign key. 37 | */ 38 | String[] value(); 39 | 40 | /** 41 | * Field referenced by foreign key. 42 | * @return Field referenced by foreign key. 43 | */ 44 | String[] refBy() default "id"; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/GenId.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Used to generate the primary key ID value when inserting data. 27 | * Unified configuration, you can use config items start with "bee.distribution.genid." in bee.properties. 28 | * @author Kingstar 29 | * @since 1.17 30 | */ 31 | @Target(ElementType.FIELD) 32 | @Retention(RetentionPolicy.RUNTIME) 33 | public @interface GenId { 34 | 35 | /** 36 | * whether override the old Id 37 | * @return the boolean value of whether override 38 | */ 39 | boolean override() default false; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/GenUUID.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Used to generate the primary key ID value (generate by UUID) when inserting data. 27 | * The field type is required to be string. 28 | * It is recommended to use a Long type ID primary key, such as @GenId, which is globally unique and efficient. 29 | * Unified configuration, you can use config items start with "bee.distribution.genid." in bee.properties. 30 | * @author Kingstar 31 | * @since 1.17 32 | */ 33 | @Target(ElementType.FIELD) 34 | @Retention(RetentionPolicy.RUNTIME) 35 | public @interface GenUUID { 36 | 37 | /** 38 | * whether override the old id 39 | * @return the boolean value of override 40 | */ 41 | boolean override() default false; 42 | 43 | /** 44 | * whether need the separator("-"),default is false. 45 | * @return the boolean value of useSeparator 46 | */ 47 | boolean useSeparator() default false; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/Geo2dsphere.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2023 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Geo2dsphere annotation for MongoDB. 27 | * @author Kingstar 28 | * @since 2.1 29 | */ 30 | @Target({ElementType.TYPE, ElementType.FIELD}) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | public @interface Geo2dsphere { 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/GridFs.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2023 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Store the file for Mongodb and register the file id to the field which define in fileIdName. 27 | * The filename from the field which define in fileName. 28 | * The file type is InputStream; 29 | * Just support INSERT type, SELECT(since 2.1.8) type. 30 | * @author Kingstar 31 | * @since 2.1 32 | */ 33 | @Target(ElementType.FIELD) 34 | @Retention(RetentionPolicy.RUNTIME) 35 | public @interface GridFs { 36 | 37 | /** 38 | * Used for Mongodb declaration. After saving the file to the database, 39 | * the file ID will be saved to the field of the fileIdName declaration (default: fileid) 40 | * @return fileId name 41 | */ 42 | String fileIdName() default "fileid"; 43 | 44 | /** 45 | * The field name corresponding to the file name 46 | * @return file name 47 | */ 48 | String fileName() default "filename"; 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/GridFsMetadata.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2023 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Mongodb GridFs Metadata just support type is Map. 27 | * Just support INSERT type; can not transfer to filter part when SELECT type. 28 | * @author Kingstar 29 | * @since 2.1 30 | */ 31 | @Target(ElementType.FIELD) 32 | @Retention(RetentionPolicy.RUNTIME) 33 | public @interface GridFsMetadata { 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/Ignore.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Ignore the field which do not want to transfer. 27 | *
It is recommended that the annotation be used as little as possible, 28 | *
because many times you can use the following features to achieve the same effect: 29 | *
the null and empty string are not handled by default. 30 | * @author Kingstar 31 | * @since 1.9 32 | */ 33 | @Target(ElementType.FIELD) 34 | @Retention(RetentionPolicy.RUNTIME) 35 | public @interface Ignore { 36 | // String value() default ""; 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/JoinTable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2020 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Annotation for tables join. 27 | * @author Kingstar 28 | * @since 1.7 29 | */ 30 | @Target(ElementType.FIELD) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | public @interface JoinTable { 33 | 34 | /** 35 | * JoinType: left join,right join,join, (full join need DB support) 36 | * @return JoinType 37 | */ 38 | JoinType joinType() default JoinType.JOIN; 39 | 40 | /** 41 | * The join on field of main table. 42 | * @return main table's join field name. 43 | */ 44 | String mainField() default ""; 45 | 46 | /** 47 | * The join on field of subtable. 48 | * @return subtable's join field name. 49 | */ 50 | String subField() default ""; 51 | 52 | /** 53 | * Subtable alias. 54 | * @return subtable alias. 55 | */ 56 | String subAlias() default ""; 57 | 58 | /** 59 | * Subtable class type, if it has same package with main table,the package name can be omitted. 60 | * (effect when using a list type Subtable) 61 | * replace by subClazz() since 1.11 62 | * @return sub Class name. 63 | * @since 1.9.8 64 | * @deprecated (since="1.11",can use subClazz() replace it.) 65 | */ 66 | @Deprecated() 67 | String subClass() default ""; 68 | 69 | /** 70 | * Subtable entity Class type. 71 | * (effect when using a list type Subtable) 72 | * @return subClass Class type. 73 | * @since 1.11 74 | */ 75 | @SuppressWarnings("rawtypes") 76 | Class subClazz() default Object.class; 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/JoinType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2020 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | /** 21 | * SQL join type. 22 | * @author Kingstar 23 | * @since 1.7 24 | */ 25 | public enum JoinType { 26 | JOIN(" join "), //inner join 27 | LEFT_JOIN(" left join "),RIGHT_JOIN(" right join "),FULL_JOIN(" full join "); 28 | 29 | String type; 30 | 31 | JoinType(String type){ 32 | this.type = type; 33 | } 34 | 35 | public String getType(){ 36 | return type; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/Jsonb.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-2024 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Just for PostgreSQL jsonb type. 27 | * @author Kingstar 28 | * @since 2.4.0 29 | */ 30 | @Target(ElementType.FIELD) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | public @interface Jsonb { 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/JustFetch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2023 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * It is used to query and obtain record information, 27 | * but not as a filter condition in WHERE part. 28 | * 29 |

eg: 30 |

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

private String fullname; 32 |

--> select CONCAT(fisrt_name,last_name) as fullname 33 | 34 |

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

eg: 36 |

@ JustFetch("name") 37 |

private String name2; 38 |

-->select name as name2 39 | 40 |

eg:(since 2.1.8) 41 |

TestUser.java 42 |

@JustFetch() //Only obtain values, do not transfer fields to select/where. 43 |

private String count1; 44 |

45 |

Condition condition=BF.getCondition(); 46 |

condition.selectFun(FunctionType.COUNT, "*", "count1"); 47 |

condition.selectField("lastName"); 48 |

condition.groupBy("lastName"); 49 |

List list =suid.select(testUser,condition); //select 50 |

51 | 52 | * @author Kingstar 53 | * @since 1.11 54 | */ 55 | @Target(ElementType.FIELD) 56 | @Retention(RetentionPolicy.RUNTIME) 57 | public @interface JustFetch { 58 | 59 | /** 60 | * Since V2.1.8,when value is empty, the corresponding field is parsed and only used to receive the result value 61 | * @return 62 | */ 63 | String value() default ""; 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/PrimaryKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Mark an property as the Primary Key.
27 | * It is not allowed to define a field named ID, but it is not defined as a primary key.
28 | * When the field name of the primary key is not "id", it can be marked as the primary
29 | * key with the PrimaryKey annotation.
30 | * When the field has Ignore annotation, the PrimaryKey annotation will also be ignored.
31 | * This annotation exists for compatibility with old systems,
32 | * It is strongly recommended to set an "id" column as the primary key when defining table in the new system. 33 | * @author Kingstar 34 | * @since 1.11 35 | */ 36 | @Target(ElementType.FIELD) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | public @interface PrimaryKey { 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/ReplaceInto.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Change "insert [into]" to "replace [into]" for insert sql. 27 | * It will affect when use in entity Javabean. 28 | * In particular, this is generally used for MySQL. 29 | * @author Kingstar 30 | * @since 1.11 31 | */ 32 | @Target(ElementType.TYPE) 33 | @Retention(RetentionPolicy.RUNTIME) 34 | public @interface ReplaceInto { 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/SysValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2020 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Annotation use in Bee for setting class' field value by properties. 27 | * @author Kingstar 28 | * @since 1.4 29 | */ 30 | @Target(ElementType.FIELD) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | public @interface SysValue { 33 | 34 | String value(); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/Table.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2020 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | 19 | package org.teasoft.bee.osql.annotation; 20 | 21 | import java.lang.annotation.ElementType; 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.RetentionPolicy; 24 | import java.lang.annotation.Target; 25 | 26 | /** 27 | * Specify or dynamic table name mapping,the value do not auto translate any more. 28 | * @author Kingstar 29 | * @since 1.8 30 | */ 31 | @Target(ElementType.TYPE) 32 | @Retention(RetentionPolicy.RUNTIME) 33 | public @interface Table { 34 | String value(); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/Updatetime.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * When updat records, the update time is automatically filled in as the current time. 27 | * If the original field has a value, it will not be override by default. 28 | * @author Kingstar 29 | * @since 1.11 30 | */ 31 | @Target(ElementType.FIELD) 32 | @Retention(RetentionPolicy.RUNTIME) 33 | public @interface Updatetime { 34 | String formatter() default ""; 35 | 36 | boolean override() default false; 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/customizable/Json.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation.customizable; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * The entity structure is converted to Jason when inserting values, 27 | *
and the Jason string is converted to entity structure when querying. 28 | *
Only valid when inserting values and query fields, not as a where condition. 29 | *
When update can only be used in entities and cannot be set with condition. 30 | *
need register to TypeHandlerRegistry and SetParaTypeConverterRegistry. 31 | * @author Kingstar 32 | * @since 1.11 33 | */ 34 | @Target(ElementType.FIELD) 35 | @Retention(RetentionPolicy.RUNTIME) 36 | public @interface Json { 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/annotation/customizable/JsonHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.annotation.customizable; 19 | 20 | /** 21 | * Json annotation Handler,is not necessary. 22 | * @author Kingstar 23 | * @since 1.11 24 | */ 25 | public interface JsonHandler { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/chain/Delete.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.chain; 19 | 20 | /** 21 | * Delete interface for standard SQL with chain programming. 22 | * @author Kingstar 23 | * @since 2.4.0 24 | */ 25 | public interface Delete extends Where, ToSql { 26 | 27 | public Delete delete(String table); 28 | 29 | public Delete truncate(String table); 30 | 31 | public Delete drop(String table); 32 | 33 | public Delete drop(); 34 | 35 | public Delete IfExists(); 36 | 37 | public Delete table(String table); 38 | } -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/chain/Insert.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2024 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.teasoft.bee.osql.chain; 19 | 20 | /** 21 | * Insert interface for standard SQL with chain programming. 22 | * @author Kingstar 23 | * @since 2.4.0 24 | */ 25 | public interface Insert extends ToSql { 26 | 27 | public Insert insert(String table); 28 | 29 | public Insert columnAndValue(String column, Object value); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/teasoft/bee/osql/chain/Select.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2024 the original author.All rights reserved. 3 | * Kingstar(honeysoft@126.com) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.teasoft.bee.osql.chain; 18 | 19 | import org.teasoft.bee.osql.OrderType; 20 | 21 | /** 22 | * Select interface for standard SQL with chain programming. 23 | * @author Kingstar 24 | * @since 1.3 25 | * @since 2.4.0 26 | */ 27 | public interface Select extends Where