Hibernate MyBatis comparison, HibernateMyBatis
I. Similarities
1. Same Architecture
Hibernate and MyBatis use the same framework, because they all encapsulate JDBC, but Hibernate encapsulates a little more completely.
2. You can use XML to create a ing file and configuration file. Annotations can also be used, but annotations are not recommended. The scope of use of annotations is relatively small.
3. For a single table, CRUD operations are relatively simple and there is no difference in the workload between the two.
4. You can use tools to generate most DAO code.
5. You can configure the secondary cache to improve the running efficiency.
6. log storage is supported. Hibernate has its own log storage mechanism. Log4j is required for MyBatis.
Ii. Differences
Summary: Hibernate is more object-oriented in my opinion. We focus on the object state, rather than what SQL statements are executed. Therefore, database operations are not as easy as using MyBatis with dynamic SQL statements. Its advantage lies in its powerful maintenance and Optimization in the future. Many items can be configured. If you need to learn all the functions of Hibernate, it will take a lot of learning costs. If you have learned this, the actual code workload will be much smaller, because you don't have to write SQL by yourself, and the performance and robustness will be much better.
MyBatis is easy-to-use and easy-to-use. It continues its good experience in SQL. It is very easy to use for projects that do not have such high requirements on object models. The cost is that the functions are relatively simple, and there is little space for optimization in the future, and all the operations on the underlying database are manually written. Many Internet companies are using MyBatis.