The difference between hibernate and mybatis?

<<< >>> similarities

  1, Hibernate and MyBatis can be generated by SessionFactoryBuilder by the XML configuration file SessionFactory, and then generate a SessionFactory Session, finally Session to open a transaction and execute SQL statements. Session, SessionFactory, SessionFactory life cycle are similar.

  2, support both JDBC and JTA transactions.

<<< >>> differences

  1, MyBatis can be more finely optimized to selectively query required fields. When more than one table simultaneously operate, MyBatis has more advantages.

  2, MyBatis easy to grasp, Hibernate more difficult to grasp, such as Hibernate Although you can not write sql statement to complete CRUD operations, but needs to be named in accordance with the established naming format, high learning costs.

  3, Hibernate objects for CRUD maintenance easier and more efficient.

  4, Hibernate database portability even better, change can be accomplished by modifying the database dialect, Hibernate automatically generates SQL statements in line according to the dialect. MyBatis database portability is not good, you need to change one by one each SQL statement after changing the database, time-consuming and labor-intensive.

  5, Hibernate better secondary cache mechanism, you can use third-party caching. MyBatis own caching mechanism provided is not convenient enough.

 

Guess you like

Origin www.cnblogs.com/XieXiyu/p/11093294.html