Hibernate MyBatis comparison, HibernateMyBatis

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.