Comparison between Hibernate and ibatis

Source: Internet
Author: User
Hibernate is currently the most popular o/R Mapping Framework. It was developed from sf.net and has become part of JBoss.

Ibatis is another excellent o/R Mapping Framework. It is a subproject of Apache.

Compared with hibernate "O/R", ibatis is Is An ORM implementation of "SQL mapping.

Hibernate provides a complete encapsulation of the database structure. hibernate's O/R Mapping implements the poing between pojo and database tables, as well as automatic SQL generation and execution. Programmers often only need to define the poing relationship between pojo and database tables to complete the persistent layer operations through the methods provided by hibernate. Programmers do not even need to be familiar with SQL. hibernate/OJB will automatically generate the corresponding SQL based on the developed storage logic and call the JDBC interface for execution.

Ibatis focuses on the poing between pojo and SQL. Then, map the SQL parameters and returned result fields to the specified pojo by ing the configuration file. There is an open-source tool abator that can generate SQL statements, which is very useful like hibernate tools.

Comparison between the two:
1. ibatis is very easy to learn, Hibernate is relatively complicated, and the threshold is high.

2. You do not need to write SQL statements because tools can be automatically generated. There are many hibernate tools. ibatis has an abator which is particularly useful for generating Bo, Dao, and XML.

3. When the system is under secondary development and cannot control or modify the database structure, ibatis is more flexible than hibernate.

4. The system has a huge amount of data processing capacity and extremely demanding performance requirements. This often means that we must use highly optimized SQL statements (or stored procedures) to achieve system performance design indicators. In this case, ibatis has better controllability and performance.

5. the po and hibernte ing obtained by one-to-one ing of database fields are completely different. The essential difference is that the Po is flat, unlike the Po mapped by hibernate, it can express the relationship between three-dimensional object inheritance, aggregation, and so on, which will directly affect the design idea of your entire software system.

6. The most important sentence is what ibatis author says:

If you are starting a new project and you're in full control of your object model and database design, Hibernate is a good choice of O/R tool.

If you are accessing any 3rd party databases (e.g. vendor supplied), or you're working with a legacy database, or even just a really poorly designed database, then an O/R mapper might not be capable of handling the situation. that's were an SQL mapper comes in handy

Conclusion: either hibernate or ibatis has its own principles:

Hibernate has powerful functions, good database independence, and strong o/R ing capabilities. If you are proficient in Hibernate and have encapsulated hibernate properly, the code for the entire persistence layer of your project will be quite simple, with few code to be written, fast development, and great.

The disadvantage of Hibernate is that it has a low learning threshold and a higher level of proficiency. In addition, how can we design o/R ing and balance the performance and object models, and how to make good use of hibernate requires your experience and capabilities.

Ibatis is easy to learn and use. It provides the Automatic Object binding function for database queries and extends the good experience in SQL. For projects that do not have such high requirements on object models, perfect.

The disadvantage of ibatis is that the framework is still relatively simple and the functions are still missing. It is not easy to adapt to quick database modification.

My suggestion is:

If your team does not have a master of hibernate, use ibatis to make good use of hibernate, it is not easy; otherwise you should choose hibernate, so that your development speed and code simplicity are quite good!

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.