Clarification about MyBatis-Flex copying MyBatis-Plus

Hello everyone, I am the author of MyBatis-Flex, sorry for taking up your time.

Recently, there have been many remarks about MyBatis-Flex plagiarizing MyBatis-Plus, with some so-called "evidence" attached, which may cause many misunderstandings.

For example: "Colder than the winter of the Internet is the heart of open source people" , and some other additional circles of friends.

So, as the author of MyBatis-Flex, I feel the need to clarify.

First, let's start with why we should write MyBatis-Flex.

MyBatis-Plus is an excellent ORM open source framework, but in more than 10 years of work, I have been a big fan of the JFinal framework. JFinal includes MVC and ORM. Therefore, I have been using JFinal in my work and rarely use other ORM. To this end, a development framework called JBoot was also developed based on JFinal. JBoot was also selected by Gitee as a GVP project (Gitee's most valuable open source project) in 2019.

By chance, our Party A asked us to use the Spring + MyBatis technology stack, so we started doing research and ORM selection, including tkMapper, Fluent-MyBatis and MyBatis-Plus.

After a period of research, we found that MyBatis-Plus has the most stars among the above open source projects. We originally planned to use MyBatis-Plus, but after reading the source code in depth, we found that its architecture may have an impact on performance, and we also found some source code comments that we disagree with, which diverges from our open source views. Therefore, The idea of ​​writing a new framework came up by myself.

For example, these comments, the official source code of MyBaits-Plus is at: https://gitee.com/baomidou/mybatis-plus/blob/3.0/mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector /methods/InsertBatchSomeColumn.java

I personally disagree with these comments.

In addition, in the technical architecture of MyBatis-Plus, the way to enhance MyBatis is to modify the SQL passed by the user through the interceptor of MyBatis, which has achieved the purpose of function expansion and enhancement.

This enhanced way has many benefits, whether the user calls the method of Mapper of MyBatis or writes SQL calls through XML. MyBatis-Plus can intercept and enhance MyBatis.

But this also has some disadvantages: that is, each enhanced SQL needs to be parsed by  JSqlParser (URL: http://github.com/JSQLParser/JSqlParser )  , which will bring a lot of additional performance loss. At the same time, as databases are changing with each passing day, each database may support its own unique features. We are worried that parsing SQL through JSqlParser will cause many problems, such as some unique SQL that cannot be parsed.

So we are thinking whether there is a way to enhance MyBatis without Sql Parser. On the official website of MyBatis, we see that it has provided methods such as , etc., which are convenient for us to execute and write SQL in java source code. @Select()SqlProvider 

After some research, we found that MyBatis' official mybatis-dynamic-sql (URL: https://github.com/mybatis/mybatis-dynamic-sql) and open source frameworks also use a similar approach: based on SqlProvider instead of Based on: Interceptor + JSqlParser. Fluent-Mybatis 

Therefore, we also decided to refer to the ways of mybatis-dynamic-sql and fluent-mybatis, and use: Mapper + SqlProvider to enhance the design pattern of MyBatis. The difference between this design pattern and the design pattern of MyBaits-Plus is huge.

However, although this design pattern improves performance, it also has disadvantages, that is, it cannot enhance the SQL written in XML. When our team was discussing internally, we suddenly had an idea: the way of writing SQL in XML, in Will it be eliminated in the future?

The answer we got is: there is this possibility!

In Spring 1.x~3.x, Spring is almost always written in the XML + Java mode. When we write code, we need to define beans in XML and then use them in java.

It has to be said that the official design of MyBatis should (or may) also "learn" from Spring's XML + Java design pattern.

But in the past two years, with the development of SpringBoot, we rarely see the scenario of writing collaborative Spring projects through XML + java. MyBatis officials should (or may) also want to abandon XML, and only in later versions have they introduced methods such @Select()as SqlProvider SQL that can be written directly in Java projects.

Later, MyBatis should (or maybe) feel that this is not thorough, so the official mybatis-dynamic-sql was launched directly to completely solve the problem of writing SQL in XML. As of today, the activity of mybatis-dynamic-sql and MyBatis Almost as tall as itself.

mybatis-dynamic-sql 官方 Git: https://github.com/mybatis/mybatis-dynamic-sql

We feel that both SpringBoot and MyBatis's mybatis-dynamic-sql are moving away from XML.

Therefore, through this series of research conclusions, we embarked on the road to start developing MyBatis-Flex.

With the release of some stable versions of Flex, we started to compare the performance of MyBatis-Flex and MyBatis-Plus. The performance test results surprised us: MyBatis-Flex is at least 5 times higher than MyBatis-Plus in many scenarios. Above, this is the test source code and conclusion: https://gitee.com/mybatis-flex/mybatis-benchmark

Our team is very happy with this conclusion. Therefore, in the five months since MyBatis-Flex was open sourced, we have worked tirelessly and forgot to sleep and eat. In this 5-month period, 50 versions were launched in a row. During this period, I had almost no weekends and no breaks.

However, for some unknown reason, I suddenly saw that the relevant developers of MyBatis-Plus released the remarks that MyBatis-Flex plagiarized MyBatis-Plus. In the process of source code such as mybatis-dynamic-sql, directly copied the source code of MyBatis-Plus?

At the same time, there are some screenshots used by some people to prove that MyBatis-Flex plagiarized MyBatis-Plus source code comparison:

But from this picture, you should be able to see that the source code acquaintance of MyBatis-Flex and MyBatis-Plus is less than 10% . And in this comparison chart, there are indeed a few files with a high degree of acquaintance, such as:

  • MyBatisSqlSessionFactoryBean

  • MyBatisPlusAtuoConfiguration

  • MyBatisSqlSessionFactoryBuilder

But MyBatis-Flex is really wronged, because these files of MyBatis-Flex are derived from MyBatis official git (not MyBatis-Plus), they are:

As for the other tool classes, it is the same. For example, DbTypeUtil is used to parse the url string configured by DataSource, and then analyze which database type it is. On this point, MyBatis-Flex does refer to MyBatis-Plus com.baomidou.mybatisplus.extension. toolkit.JdbcUtils and com.alibaba.druid.util.JdbcUtils#getDbType of Druid data sources and part of the source code of Druid (not a complete copy, source URL: https://github.com/alibaba/druid/blob/master/ core/src/main/java/com/alibaba/druid/util/JdbcUtils.java ). JdbcUtils.getDriverClassName  

At this point, I think my clarifications should be almost complete, I hope I don't take up too much time, sorry again.

Open source is not easy. Finally, I hope everyone will not make malicious comments and vent their emotions.

A good word is warm in three winters, and a bad word hurts people in June.

Guess you like

Origin www.oschina.net/news/251325