# bee **Repository Path**: distributed-orm/bee ## Basic Information - **Project Name**: bee - **Description**: Bee是一个具有人工智能(AI)特性,开发速度快、简单、自动高效的Java ORM框架!它的编码复杂度是O(1),不管操作多少张表,都可以不需要写额外的Dao代码。Bee同时支持面向对象和自定义SQL两种方式,简单场景和复杂场景都可以应用。 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: https://gitee.com/automvc/bee - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 135 - **Created**: 2020-06-21 - **Last Updated**: 2022-06-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README Bee ========= **Easy for Stronger.** **Bee** is an ORM framework. **Bee** is an easy and high efficiency ORM framework. **Coding Complexity is O(1),it means that Bee will do the Dao for you**. **You don't need to write the Dao by yourself anymore**.Help you to focus more on the development of business logic. **Good Feature:** AI, Timesaving/Tasteful, Easy, Automatic (**AiTeaSoft Style**) **Good News:** 1)**V1.17 add support Android and HarmonyOS ORM function** 2)In **Android and HarmonyOS** environment can use the **same ORM code with Bee** **Bee** see: https://github.com/automvc/bee bee-ext: https://github.com/automvc/bee-ext ## [中文介绍](../../../bee/blob/master/README_CN.md) [点击链接可查看中文介绍](../../../bee/blob/master/README_CN.md) ## Requirement jdk1.7+ ## Feature & Function: **Support many Database**(MySQL,MariaDB,Oracle,H2,SQLite,PostgreSQL,SQL Server,Cassandra and so on) and easily extend. **Good performance, close to the speed of JDBC; Small files:Bee V1.8 jar 217k**, **V1.9.5 jar,315k, V1.9.8 jar 310k**. In addition to **JDBC, Android and HarmonyOS** are also supported. * 1.The interface is simple and easy to use, **Suid (select,update,insert,delete)** object-oriented operation. * 2.All Suid(select,update,insert,delete) operation use the same Bee interface,no longer need new dao interface. * 3.Convention-over-configuration:Javabean can no annotation,no xml. * 4.Automatic filter the null and empty field for default. * 5.Select some fields easily. * 6.Dynamic & random combination of query conditions,no need to prepare the interface in advance; new query requirements, no need to change the query interface. * 7.Native SQL sort support,native paging support(do not need select all records before). * 8.Support return the JSON format query results directly; Chain programming. * 9.Support:transaction ,same connection,for update,batch insert,procedure. * 10.more tables select oriented object support(has not the n+1 problem,one to one,one to many,many to one,many to many).sub-field type support Javabean or List. * 11.L1 cache, simple in concept and powerful in function; L1 cache can also be fine tuned like the JVM; Support updatable long-term cache list and update configuration table without restart. Inherently resistant to cache penetration. L2 cache extension support; Redis L2 cache support. * 12.Support java_db naming translation and support customize,default implement. * 13.Many DB supports easy extension(MySQL,MariaDB,Oracle,H2,SQLite,PostgreSQL,SQL Server,Cassandra,etc. are directly available),In theory, can support all DB which support JDBC. * 14.Add multi-DataSource support(Write/Read, only Split Database);support Jndi DataSource. * 15.Support use many type database at the same time(eg: use Mysql,Oracle,SQL Server at the same). * 16.Support distributed primary key(global unique id,Serial distributed unique id in one workid). * 17.The same database sub table support, dynamic table name mapping support. * 18.Support interceptor、multi-tenant,convert PreparedStatement parameter,custom TypeHandler and process the ResultSet. * 19.Suid,SuidRich,PreparedSql,MapSuid,MoreTable support set the dataSource name. * 20.MapSuid:opertate(suid) the database no need Javabean. * 21.No third-party plug-in dependency; It can be used in zero configuration. * 22.**Good performance, close to the speed of JDBC**; Small files:Bee V1.8 jar 217k, **V1.9.5 jar,315k, V1.9.8 jar 310k**. **Assist function**: * 23.Automatically generate the Javabean via DB table or view.Automatically create table via the Javabean,JavaWeb back-end code;Can print non placeholder executable SQL statements to facilitate debugging; support generate JSON format SQL scripts. * 24.Support reading excel and importing data from Excel to DB easily. * 25.Stream tool class streamutil. * 26.The front and back ends of complex queries can be automatically parsed. * 27.Annotation support:PrimaryKey,Datetime,Createtime,Updatetime;JustFetch,ReplaceInto(MySQL). * 28.Extensible annotation: multi tenant, fuzzy processing of sensitive information, automatic setting of field values, dictionary conversion, dicti18n multilingual International Dictionary conversion, column name and field name mapping. ## Newest Function **V1.17** **V1.17.0.7** 1)**add support HarmonyOS ORM function** 2)In **HarmonyOS and Android** environment can use the same ORM code with Bee **V1.17.0.6** 1)**add support Android ORM function,you can use Bee for SQLite DB in Android environment.** 2)support android.util.Log 3)Ddl: optimize process if the table is exist 4)add log tip the dsName(dataSource name) when multi-dataSource 5)when paging , the size is 0, return emptyList V1.17.0.5 1)Sql Server support (start,size) paging 2)@Tran transaction annotation **V1.11**(**International Labour Day**) **Detail:** V1.11.0.1.1(**2022 New Year**) SuidRich add method: public long insertAndReturnId(T entity,IncludeType includeType); PreparedSql add method: public List select(String sql,T returnType); add annotation PrimaryKey MapSqlKey support PrimaryKey BF is shortcut for BeeFactoryHelper Enhance:config info add trim() about multi-DataSource Write/Read fix a bug for naming transfer V1.11.0.2.1(**2022 Spring Festival**) add function: Interceptor、multi-tenant add Interceptor,InterceptorChain add DefaultInterceptor,CommInterceptorChain,DefaultInterceptorChain V1.11.0.2.4(**2022 Beijing Winter Olympics**) level tow ext cache support Redis cache support add BeeExtCache,DefaultBeeExtCache add BeeExtRedisCache V1.11.0.2.15(**2022 the Lantern Festival**) add annotation:Datetime,Createtime,Updatetime;JustFetch add support Jndi DataSource check MapSqlKey value V1.11.0.2.20(**Honor**) Optimize use different Database Type at same time(multi-Ds) Support use differnt type Database at the same time(eg:use Mysql,Oracle,SQL Server at same time) PreparedSql,MapSuid support Interceptor Suid,PreparedSql,MapSuid support get DataSource,get InterceptorChain Suid,PreparedSql,MapSuid,MoreTable add method:setDataSourceName,getDataSourceName,getInterceptorChain add Annotation: AnnotationHandler,AutoSetString Desensitize ReplaceInto,MySQL replace into MultiTenancy BeforeReturnAnnotationHandler,AbstractDictI18nDefaultHandler Dict DictI18n V1.11.0.2.28 (**Special Day**) add ShardingStruct prepare for sharding. add Column annotation support to extend mapping column and Javabean field name. support custom TypeHandler,and process the ResultSet. PreparedSql custom sql support more table select,and return more table struct Javabean. fixed bug: More table self association query of the same entity forbid multi-self-cycles V1.11.0.3.8 (**Lady First**) add SetParaTypeConvert for convert PreparedStatement parameter. Javabean use java.util.Date type for SUID compatibility processing. SQLite get the timestamp result for conversion. The Json field of DB is automatically converted to the attribute marked with Json annotation of Javabean(Javabean structure corresponding to Json). V1.11.0.3.12 (**Tree Planting Day**) Ddl.java uses Javabean to create tables, supports the mapping between Java and DB field types, and supports the setting java_dbtype mapping. Ddl.java is compatible with raw char type and java.util.Date. PreparedSql support batch insert. Support Suid instance set NameTranslate. Add DbFeature Registry,it is easy for setting custom database dialect. Support Cassandra. V1.11.0.3.20 (**Spring Equinox**) add Custom dynamic SQL token,@in,@toIsNULL1,@toIsNULL2,<if isNotNull>,<if isNotBlank>. dynamic SQL list transfer list to SQL in eg:in (1,2,3),no need foreach;batch insert also no need foreach. Separate CN and EN API. V1.11.0.4.22 (**The World Earth Day**) Add registry interface; Add nameregistry. Change serializer throws exceptions type. Mapsuid and mapsql support parsing string to boolean type. Genbean, which does not support JDBC type, reminds you which file to set; Genbean support config where override the old file; Genbean support gen javabean's field file; SuidRich's method selectString support variable-length arguments: public List selectString(T entity,String... selectFields); CommInterceptorChain check whether add same class. SystemLogger supports setting log level to facilitate development and debugging. The logger add method: public static void debug (string MSG, throwable T) (convenient for development and debugging). Nocache add log prompt. Improve cache security. Add preload SPI interface Preload. Add InterceptorChainRegistry, an interceptor registrar for global use. Add configuration item: pagingWithLimitOffset notCatchModifyDuplicateException notShowModifyDuplicateException fixed bug for type converter. fixed bug about @PrimaryKey in Suid update(entity). V1.11.0.4.29 The configuration file supports multi-environment differentiated configuration. SuidRich,public int update(T oldEntity, T newEntity) Interceptors only handle newEntity. ## [Function Detail](../../../bee/blob/master/Changed_Log.md) [click for: Function Detail](../../../bee/blob/master/Changed_Log.md) ## ORM Compare [ORM-Compare (More Detail)](../../../orm-compare) Test Evn : Local windows. DB: MySQL (Version 5.6.24). Test point: Batch Insert;Paging Select; Transaction(update and select).
Batch Insert(unit: 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

 

Paging Select(unit: 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

 

Transaction(update and select) (unit: 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 need files** orm\compare\bee\service\BeeOrdersService.java **MyBatis need files** 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 common,Javabean and Service interface: Orders.java OrdersService.java Quick Start: ========= ## 1. Add Bee #### 1.1 if it is a maven project,add the following dependency ```xml org.teasoft bee 1.11 org.teasoft honey 1.11 org.teasoft bee-ext 1.11 ``` #### 1.2 Of course, can download the jar file directly ## 2. Create the database and the table eg: Create one database,default name is bee. Create the tables and init the data by run the [init-data(user-orders)-mysql.sql](../../../bee-exam/blob/master/src/main/resources/init-data(user-orders)-mysql.sql) file(it is mysql sql script). ## 3. Update the database configuration in bee.properties if need If no the bee.properties file, you can create it by yourself. \#bee.databaseName=MySQL bee.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. The Javabean Orders reference as below: [Orders(Javabean)](../../../bee-exam/blob/master/src/main/java/org/teasoft/exam/bee/osql/entity/Orders.java) [Auto Genernate Javabean](../../../bee-exam/blob/master/src/main/java/org/teasoft/exam/bee/osql/autogen/GenBeanExam.java) ## 5. Run the following java code ```java import java.math.BigDecimal; import java.util.List; import org.teasoft.bee.osql.BeeException; import org.teasoft.bee.osql.Suid; import org.teasoft.honey.osql.core.BeeFactoryHelper; import org.teasoft.honey.osql.core.Logger; /** * @author Kingstar * @since 1.0 */ public class SuidExamEN { public static void main(String[] args) { try { Suid suid = BeeFactoryHelper.getSuid(); Orders orders1 = new Orders();//need gen the Javabean orders1.setId(100001L); orders1.setName("Bee(ORM Framework)"); List list1 = suid.select(orders1); // 1. select for (int i = 0; i < list1.size(); i++) { Logger.info(list1.get(i).toString()); } orders1.setName("Bee(ORM Framework)"); int updateNum = suid.update(orders1); //2. update Logger.info("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 int insertNum = suid.insert(orders2); // 3. insert Logger.info("insert record:" + insertNum); int deleteNum = suid.delete(orders2); // 4. delete Logger.info("delete record:" + deleteNum); } catch (BeeException e) { Logger.error("In SuidExamEN (BeeException):" + e.getMessage()); e.printStackTrace(); } catch (Exception e) { Logger.error("In SuidExamEN (Exception):" + e.getMessage()); e.printStackTrace(); } } } // notice: this is just a simple sample. Bee suport transaction,paging,complicate select,slect json,and so on. ``` #### [More example/test case](../../../bee-exam/) #### [Bee+Spring-boot Demo](../../../bee-starter-demo/) ### Bee Architecture ### Bee Common Interface Rapid application development: ========= **Let Java more quicker programming than php and Rails.** **Faster development of new combinations for Java Web:** [Bee+Spring+SpringMVC](../../../../aiteasoft/bee-spring-springmvc) **Faster development of new combinations for Spring Cloud microservices:** [Bee + Spring Boot](../../../bee-springboot) ### KmCoding [Rapid Application Code Generation Platform](http://www.kmcoding.com)--AiTea Soft made in China! ... Other Document: ========= ### API-DOC API-V1.9.8 SourceCode contain bee-1.9.8-javadoc.zip API-V1.11(Newest) SourceCode contain bee-1.11 CN & EN API,bee-1.11 CN SourceCode [wiki Document](../../../bee/wikis) [CSDN: ORM Bee Document](https://blog.csdn.net/abckingaa/article/details/121664398) Enterprise Edition: ========= In order to provide more and more powerful functions, Bee team cooperates with the enterprise to launch the Enterprise Version. ### New Features We hope to provide more easy-to-use Bee functions to further improve the efficiency of development! * 1.Reduce the difficulty of development financial computing projects, simplify financial digital calculation, etc * 2.@AutoSetString annotation ease of use improvement, easy to handle automatic filling functions such as CreateBy,UpdateBy Automatically insert values for tenants * 3.@Desensitize, change some sensitive information to mask characters * 4.@Dict specific field dictionary value conversion * 5.@DictI18n multilingual International Dictionary conversion, global unified setting, no need to set one by one, saving time and effort * 6.@MultiTenancy multi-tenant * 7.@Column when Javabean attribute is inconsistent with the table column name, define the mapping relationship (not recommended for new system, mainly for compatibility with old system) * 8.@Json Entity properties are Javabean and the JSON type column of DB table are converted automatically during parameter setting and query results * 9.Support the automatic generation of EDI XML electronic message ### Price **Enterprise** users: USD 199.00 **Personal** users: USD 49.00 ### Expiration Dates **Permanent use after purchase,Get upgrades for free** ### Technical Support **The use of Enterprise Edition, professional technical support and solution consultation are provided by the following companies:** **[Shenzhen Caifeng software](http://www.aiteasoft.com)** (Enterprises willing to join in, please contact us!) ### Discount(2022) Before June: 40% discount Before July: 30% discount Before August: 20% discount Before October: 10% discount Contact & Welcome: ========= #### Author's email: honeysoft@126.com #### If you have any problem on bee, please let me know kindly! Thank you, so much! #### ORM QQ Group: 992650213 WeChat:AiTeaSoft #### At the same time, welcome you to join Bee team create a better future.