Comparison between mybatis and hibernate

Same point:

(1) Both Hibernate and MyBatis generate SessionFactory from XML configuration file through SessionFactoryBuider, SessionFactory generates Session, and Session is used to open execution transactions and SQL (Structured Query Language) statements.

(2) Both Hibernate and MyBatis support JDBC (Java DataBase Connectivity, java database connection) and JTA (Java Transaction API, Java Transaction API (Application Programming Interface, application programming interface)) transaction processing.

Note: The main role of jdbc and jta is to enhance data access capabilities.

(3) Based on the idea of ​​ORM (Object Relational Mapping, Object Relational Mapping), the mapping problem between entity and database is solved

 

difference:

(1) SQL: Mybaits maintains the mapping results through mapper.xml. Compared with hibernate’s automatic generation of hql (hibernate sql), it is more flexible for programmers to manually write sql, and the sql tuning is easier (hibernate has better encapsulation and improved development efficiency. At the same time, sql statement tuning is more laborious, of course, you can manually modify sql to optimize, but it will also affect the development efficiency); hibernate's hql database has better portability, which is reflected in its robustness.

(2) In terms of caching: both mybatis and hibernate can use third-party caching, and hibernate has a better secondary caching mechanism than maybatis.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325202545&siteId=291194637