Now the web is full of comparisons between Jpa and Mybatis. In fact, in a narrow sense, hibernate and Mybatis are compared.

For example: why do I feel that mybatis, which is popular in China, seems to be used by no one abroad?

Here are some screenshots

I’m not one to judge, but THIS time I couldn’t help it.

  • Hibernate has a long history but doesn’t mean it’s obsolete. Is Mybatis the future? Definitely not. Database is used to save data, league table query data structure design is a lot of it will only be a problem, just don’t want to admit or lack of anyone to sort screening data, the complex operation in the relational database to do it, why don’t god ah, is this your uncle called gree warehouse to take material for you, By the way, let him calculate the power loss of the new compressor according to various factors. Data analysis should never be left to a relational database. It’s called each in its own right.
  • The logic of this statement is interesting:UPDATE items SET price = 11 WHERE id = 1111, don’t you need to take out the data before updating the data? Yes, if there is a little bit of concurrent demand, either optimistic locking or pessimistic locking, you need to query the latest data, right? Pessimistic locking, optimistic check Version. Hibernate can specify local field updates for a full field write-back database
  • Report logic is real! This may be an excuse to let programmers do the job of analyzing data through a relational database, but programmers don’t enjoy it
  • Microservices are all over the place with foreign keys, lots of syntable queries, and hundreds of rows of SQL statements. Define a good business boundary, split into independent subsystems, or to a certain scale, let alone Hibernate can not do this work, Mybatis handwriting SQL how, also can not do, don’t believe a large factory of high flow data nail a foreign key try, see their technical director will take the knife chase. The scale of small companies is often far from reaching that kind of unsustainable degree, and the high volume of business data of large factories is not forced here…
  • If you want to transfer your company’s database from mysql to Oracle, MongoDB, SQLServer or other database, using Mybatis, please ask you to panic. Spring’s official support for JPA is not unfounded. Jpa shields underlying differences.

Since Jpa is easy to use, there is no need to follow the steps of some big factories, step by step, like the pace of the devil!

As Taobao technology said in ten years:

For example, the user module, the old member.taobao.com continues to be maintained without adding new functions. The new functions are developed on the new module and share the same database with the old module. After development, they are put on different application clusters. Replace one, turn off one of the functions on the old module, gradually direct the user to Member1.taobao.com, and then close member.taobao.com when all the functions are replaced. From the design point of view, the secondary domain name of Member1 should be a transitional state, but after we took the code of member domain offline, we found it difficult to switch member1 back to member, because some links were written dead. So for a long time we used the strange domain member1.taobao.com. A year later, when another Internet company started e-commerce, we had to laugh to find their domain names member1.xx.com and Auction1.xx.com, too, copied so well.

Yes, I use JPA, and I love the design philosophy of JPA. But at the same time, I think Mybatis is also a very good framework, which can efficiently solve many problems and meet the needs of many enterprises. Give me a big thumbs up.

Technology is only a way to solve problems, a tool, the choice of which technology varies from person to person, the existence of reasonable.