1 Star 1 Fork 132

automvc / bee

forked from automvc / bee 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

Bee

好消息:

**2022年5月1日(劳动节)**前登记的企业用户,可获得专业的生产环境使用帮助,为你的系统保驾护航、提高性能;
个人用户登记后入群,可获得个性化的使用咨询!
登记地址:
https://gitee.com/automvc/bee/issues/I3PIUJ
https://github.com/automvc/bee/issues/43

完成登记的伙伴,请加QQ群(992650213),找群主领资料!

工欲善其事必先利其器!——《论语·卫灵公》

为适应互联网时代软件需求量大,需求变更频繁,性能要求高等要求,ORM Bee应运而生!

Bee,互联网新时代的Java ORM框架,更快、更简单、更自动,开发速度快,运行快,更智能!
Bee,一个简单,易用,功能强大(编码少、开发速度快,运行快)的 JAVA ORM 框架。
Bee简单易用:单表操作、多表关联操作,可以不用写sql,极少语句就可以完成SQL操作;概念简单,10分钟即可入门。
Bee功能强大:复杂查询也支持向对象方式,分页查询性能更高,一级缓存即可支持个性化优化;具有分布式特性。高级要求,还可以方便自定义SQL语句。运行速度接近直接用JDBC的速度。
如果说Mybatis在Hibernate之后不是重复造轮子,那Bee在Hibernate和Mybatis之后也不会是重复造轮子!
择其优点,避其缺点,此外,还加有自己的优点!

磨刀不误砍柴工! Bee连磨刀的时间都帮你省了。

Bee 是一个具有人工智能(AI)特性,省时/优雅、简易、自动( AiTea: Timesaving/Tasteful, Easy, Automatic) 的ORM软件框架(AiTeaSoft)(IT-->AiTea 的思维转变!)。
Bee是一种更接近SQL语言思维的ORM框架,
一种开发速度和开发成本都不比Php,Ruby on Rail差的Java ORM框架,
而且它的编码复杂度是O(1),即用了Bee,无论多少个表,你都可以不用另外再写dao代码;让你可以更专注业务逻辑的开发

Bee 网址:
https://github.com/automvc/bee
Bee在gitee 的网址:
https://gitee.com/automvc/bee

环境要求

jdk1.7+

Bee主要功能特点介绍:

Bee概念简单(10分钟即可入门)、功能强大。
Bee 简化了与DB交互的编码工作量.连接,事务都可以由Bee框架负责管理。

省时,开发速度快

简单易用

  • 1.接口简单,使用方便。Suid接口中对应SQL语言的select,update,insert,delete操作提供4个同名方法
  • 2.使用了Bee,你可以不用再另外编写dao代码,直接调用Bee的api即可完成对DB的操作。
  • 3.约定优于配置:Javabean没有注解,也不需要xml映射文件,只是纯的Javabean即可,甚至get,set方法不用也可以。
  • 4.智能化自动过滤null和空字符串,不再需要写判断非空的代码。
  • 5.支持只查询一部分字段

自动,功强强大

  • 6.动态/任意组合查询条件,不需要提前准备dao接口,有新的查询需求也不用修改或添加接口。
  • 7.支持原生SQL排序, 原生语句分页(不需要将全部数据查出来)。
  • 8.支持直接返回Json格式查询结果; 链式编程。
  • 9.支持事务、多个ORM操作使用同一连接、for update,支持批处理操作,支持原生SQL(自定义sql语句),支持存储过程
  • 10.支持面向对象方式复杂查询、多表查询(无n+1问题; 支持:一对一,一对多,多对一,多对多;返回结果根据子表是否使用List有两种呈现结构)。
  • 11.一级缓存,概念简单,功能强大;一级缓存也可以像JVM一样进行细粒度调优支持可更新的长久缓存列表,更新配置表,不需要重启。天生抵御缓存穿透 。 二级缓存扩展支持;Redis二级缓存支持
  • 12.表名与实体名、字段名与属性名映射默认提供多种实现,且支持自定义映射规则扩展
  • 13.多种DB支持轻松扩展(MySQL,MariaDB,Oracle,H2,SQLite,PostgreSQL,SQL Server,Cassandra等直接可用),理论上支持JDBC的DB都可以支持。
  • 14.支持读写分离一主多从, 仅分库多数据源模式(对以前的代码无需修改,该功能对代码是透明的,即无需额外编码);Jndi数据源支持。
  • 15.支持同时使用多种数据库(如同时使用Mysql,Oracle,SQL Server)
  • 16.提供自然简单的分布式主键生成方案:分布式环境下生成连续单调递增(在一个workerid内),全局唯一数字id
  • 17.支持同库分表,动态表名映射
  • 18.拦截器、多租户,支持自定义TypeHandler,处理查询的ResultSet结果
  • 19.Suid,SuidRich,PreparedSql,MapSuid,MoreTable支持设置数据源名称
  • 20.可以不用表对应的Javabean也能操作DB。
  • 21.第三方插件依赖;可零配置使用。
  • 22.性能好:接近JDBC的速度;文件小:Bee V1.8 仅217k, V1.9.5 仅315k,V1.9.8 仅310k
    辅助功能:
  • 23.支持自动生成表对应的Javabean,根据Javabean创建表,Javaweb后端代码根据模板自动生成;能打印非占位符的可执行sql,方便调试;支持生成Json格式的SQL脚本。
  • 24.支持读取Excel,从Excel导入数据到DB,操作简单。
  • 25.流的工具类StreamUtil。
  • 26.复杂查询前后端可自动解析。
  • 27.注解支持:PrimaryKey,Datetime,Createtime,Updatetime;JustFetch,ReplaceInto(MySQL)。
  • 28.可扩展注解:多租户,敏感信息模糊处理,自动设置字段值,Dict字典转化,DictI18n多语言国际化字典转化,Column列名与属性名映射。

最新功能介绍:

V1.11
V1.11.0.1.1(2022新年版)
SuidRich增加方法:
public long insertAndReturnId(T entity,IncludeType includeType);
PreparedSql增加方法:
public List select(String sql,T returnType);
增加声明主键支持:
add annotation PrimaryKey
MapSqlKey support PrimaryKey
可用BF代替BeeFactoryHelper加快输入
增强:读写模式配置信息去除空格
fix a bug for naming transfer

V1.11.0.2.1(2022春节版)
拦截器、多租户
add Interceptor,InterceptorChain
add DefaultInterceptor,CommInterceptorChain,DefaultInterceptorChain

V1.11.0.2.4(2022北京冬奥会版)
二级缓存扩展支持
Redis缓存支持
add BeeExtCache,DefaultBeeExtCache
add BeeExtRedisCache

V1.11.0.2.15(2022元宵节版)
添加注解:Datetime,Createtime,Updatetime;JustFetch
添加Jndi数据源支持
检测MapSqlKey的值

V1.11.0.2.20(荣耀)
multi-DS同时使用不同类型DB优化
支持同时使用多种数据库(如同时使用Mysql,Oracle,SQL Server)
PreparedSql(自定义sql),MapSuid:拦截器,多数据源支持
Suid,PreparedSql,MapSuid支持设置数据源名称,获取拦截器链
Suid,PreparedSql,MapSuid,MoreTable增加方法:setDataSourceName,getDataSourceName,getInterceptorChain
增加注解:
AnnotationHandler,AutoSetString自动设置字符值
Desensitize,敏感信息模糊处理
ReplaceInto,MySQL replace into转换
MultiTenancy多租户
BeforeReturnAnnotationHandler,AbstractDictI18nDefaultHandler
Dict字典转化
DictI18n多语言国际化字典转化

V1.11.0.2.28 (Special Day)
增加ShardingStruct为分库分表作准备
Column列名与属性名映射扩展支持
支持自定义TypeHandler,处理查询的ResultSet结果
PreparedSql自定义sql支持多表查询,返回多表关联Javabean结构数据
fixed bug:
多表查询同一个实体自我关联查询禁止自我多次循环

V1.11.0.3.8 (Lady First)
增加SetParaTypeConvert转化PreparedStatement参数.
Javabean使用java.util.Date类型,进行SUID作兼容处理.
SQLite获取Timestamp结果作转化处理.
实体属性是Javabean与DB表Json类型字段在参数设置与查询结果时自动转换(使用Json注解自定义实现).

V1.11.0.3.12 (植树节版)
Ddl.java使用Javabean创建表,支持追加java与db字段类型映射,支持设置某个DB的java_dbtype类型映射.
Ddl.java兼容原生char类型,兼容java.util.Date.
PreparedSql自定义sql支持批量插入.
支持在Suid等对象设置命名转换器.
增加DbFeature方言注册器,自定义实现不同DB方言更加易用.
支持Cassandra.
showExecutableSql添加List,Set,Map,UUID支持.

V1.11.0.3.20 (春分)
自定义动态SQL标签,@in,@toIsNULL1,@toIsNULL2,<if isNotNull>,<if isNotBlank>.
动态sql,将list转为像in (1,2,3)的语句,不需要foreach,批量插入也不需要foreach.

详细完整功能介绍

点击链接可查看 详细完整功能介绍

ORM比较

ORM-Compare (More Detail)

测试环境: Windows.
数据库: MySQL (Version 5.6.24).
测试点: 批量插入;分页查询;事务(update and select).

批量插入(单位: ms)
  5k 1w 2w 5w 10w
Bee 529.00 458.33 550.00 1315.67 4056.67
MyBatis 1193 713 1292.67 1824.33 Exception

 

分页查询(单位: ms)
  20次 50次 100次 200次 500次
Bee 17.33 58.67 52.33 38.33 57.33
MyBatis 314.33 446.00 1546.00 2294.33 6216.67

 

事务(update and select) (单位: ms)
  20次 50次 100次 200次 500次
Bee 1089.00 70.00 84.00 161.33 31509.33
MyBatis 1144 35 79.67 146.00 32155.33

Bee需要的文件
orm\compare\bee\service\BeeOrdersService.java

Mybatis需要的文件(对一个表的操作,就会比Bee多三个dao相关文件)
orm\compare\mybatis\service\MybatisOrdersService.java orm\compare\mybatis\dao\OrdersDao.java orm\compare\mybatis\dao\OrdersMapper.java orm\compare\mybatis\dao\impl\OrdersDaoImpl.java

公共都需要的有,Javabean和Service接口:
Orders.java
OrdersService.java

用Bee无需用户再写Dao代码,一个表少三个Dao文件,100个表就少300个Dao文件.

快速开始:

1. 引入Bee

1.1 maven工程,添加如下依赖

		<dependency>
			<groupId>org.teasoft</groupId>
			<artifactId>bee</artifactId>
			<version>1.9.8</version>
		</dependency>
		<dependency>
			<groupId>org.teasoft</groupId>
			<artifactId>honey</artifactId>
			<version>1.9.8</version>
		</dependency>
		<!--for log framework,Excel(poi) -->
		<dependency>
			<groupId>org.teasoft</groupId>
			<artifactId>bee-ext</artifactId>
			<version>1.9.8</version>
		</dependency>

1.2 也可以直接下载jar文件

2. 创建数据库和表

举例如下:
创建一个数据库,默认名称为bee.
可以用init-data(user-orders)-mysql.sql脚本创建表和插入初始化数据.

3. 更新数据库的配置信息(在bee.properties)

注:如果还没有bee.properties文件,可以自己新建一个.
也可以配置数据源(此处只是一个例子).

#bee.databaseName=MySQL
bee.db.dbName=MySQL
bee.db.driverName = com.mysql.jdbc.Driver
#bee.db.url =jdbc:mysql://localhost:3306/bee?characterEncoding=UTF-8
bee.db.url =jdbc:mysql://127.0.0.1:3306/bee?characterEncoding=UTF-8&useSSL=false
bee.db.username = root
bee.db.password =

4. 生成Javabean Orders可参考:

Orders(Javabean)
自动生成Javabean

5. 运行下面的 java代码

		
import java.math.BigDecimal;
import java.util.List;

import org.teasoft.bee.osql.Suid;
import org.teasoft.honey.osql.core.BeeFactoryHelper;

/**
 * 查,改,增,删 Suid (select,update,insert,delete)实例
 * @author Kingstar
 * @since  1.0
 */
public class SuidExam {
	
	public static void main(String[] args) {

		Suid suid=BeeFactoryHelper.getSuid();
		
		//需要先生成相应的Javabean
		Orders orders1=new Orders();
		orders1.setId(100001L);
		orders1.setName("Bee(ORM Framework)");
		
		//1:select查询实例
		//默认不处理null和空字符串.不用再写一堆的判断;其它有值的字段全部自动作为过滤条件
		List<Orders> list1 =suid.select(orders1);  //select
		for (int i = 0; i < list1.size(); i++) {
			System.out.println(list1.get(i).toString());
		}
		
		//2:update更新实例
		orders1.setName("Bee--ORM Framework");
		//默认只更新需要更新的字段. 过滤条件默认只用id字段,其它需求可用SuidRich中的方法.
		int updateNum=suid.update(orders1);   //update
		System.out.println("update record:"+updateNum);
		
		
		Orders orders2=new Orders();
		orders2.setUserid("bee");
		orders2.setName("Bee(ORM Framework)");
		orders2.setTotal(new BigDecimal(91.99));
		orders2.setRemark("");  //empty String test
		
		//3:insert 插入实例
		int insertNum=suid.insert(orders2); //insert  		
		//默认不处理null和空字符串.不用再写一堆的判断;其它有值的字段全部自动插入数据库中. 
		//方便结合DB插值,如id自动增长,由DB插入;createtime由DB默认插入
		System.out.println("insert record:"+insertNum);
		
		//4:delete 删除实例
		//默认不处理null和空字符串.不用再写一堆的判断;其它有值的字段全部自动作为过滤条件
		//int deleteNum=suid.delete(orders2);   //delete
		//System.out.println("delete record:"+deleteNum);
		
	}
}
//注意: 事务,分页,排序,范围查询,查询结果直接返回json等都支持,这里只是一个入门例子.
//更加应用参考,请查看: 更多例子   和    综合应用 .

更多例子/测试用例

Bee+Spring-boot Demo

API-DOC

API-V1.9.5

API-V1.9.8(最新版) 下载代码含有 bee-1.9.8-javadoc.zip

Bee架构介绍

Bee常用接口介绍

综合应用:

Java快速编程, 让Java的开发速度超过php和Rails。

更快的开发Java Web的新组合:
Bee+Spring+SpringMVC
包括仅分库多数据源实例

Bee+Spring+SpringMVC开发学校教务管理与分数管理系统

更快的开发Spring Cloud微服务的新组合:
Bee + Spring Boot

......

FAQ常见问题

点击链接可查看 FAQ常见问题

其它学习资料:

wiki 文档

CSDN: ORM Bee资料大全

联系与欢迎:

作者的电子邮箱email: honeysoft@126.com

如有任何相关建议,欢迎给作者发邮件,不胜感激!

更多设计思想,请关注微信公众号: 软件设计活跃区

为了能及时解答大家的疑问,可以加入Bee的技术QQ群:992650213

同时,也欢迎你加入到Bee框架的开发之中,相信有你的加入,Bee会更加美好!

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

Bee是一个具有人工智能(AI)特性,开发速度快、简单、自动高效的Java ORM框架!它的编码复杂度是O(1),不管操作多少张表,都可以不需要写额外的Dao代码。Bee同时支持面向对象和自定义SQL两种方式,简单场景和复杂场景都可以应用。 展开 收起
Java
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/automvcsoft/bee.git
git@gitee.com:automvcsoft/bee.git
automvcsoft
bee
bee
master

搜索帮助