Open-source ORM framework ibatis

Source: Internet
Author: User

Apart from hibernate, another popular ORM framework, ibatis, is also widely used. The difference between the two is that hibernate provides an "one-stop" ORM solution, while ibatis provides a "semi-automated" ORM implementation.

Hibernate provides a full set of ing mechanisms from pojo to database tables. Developers usually only need to define the poing between pojo and database tables to complete the persistent layer operations through the methods provided by hibernate, you do not even need to be familiar with SQL, because hibernate will automatically generate the corresponding SQL and call the JDBC interface for execution. However, Hibernate's "one-stop" solution does not apply to all situations, such:

1. Some systems only provide developers with SQL queries (or stored procedures) to obtain the required data based on security considerations. The specific table structure is not disclosed.

2. Some systems require that all database operations involving the business logic must be implemented by stored procedures at the database layer, such as the financial industry.

3. Some systems have a huge amount of data processing and extremely demanding performance requirements. This often means that the system performance design indicators must be achieved through a highly optimized SQL statement (or stored procedure.

In these scenarios, fully automated hibernate cannot meet the requirements, and ibatis can solve this problem. It defines the ing between pojo and SQL, but it does not automatically generate SQL Execution for developers during runtime. The specific SQL needs to be compiled by themselves, then, map the SQL parameters and returned result fields to the specified pojo through the ing configuration file.

Interview questions: What are the advantages and disadvantages of ibatis compared with hibernate?

A: Hibernate and ibatis are both widely used ORM frameworks, but the former provides a "one-stop" solution, while the latter is a "semi-automatic" implementation method. Ibatis has the following advantages:

1. ibatis is applicable to these scenarios. For example, when the system cannot provide a relatively complete table structure, and when the security is relatively high, it can only provide SQL or stored procedures, such as projects in the financial industry. In addition, when the system has a large amount of data processing capacity and extremely demanding performance requirements, ibatis can be used for better controllability.

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

3. The learning threshold for Hibernate is not low, and it is more difficult to master it. How to design o/R ing has a great impact on performance.

Disadvantages:

1. ibatis requires a handwritten SQL statement or a part of it. hibernate can basically generate it automatically and occasionally write hql. For the same requirement, the workload of ibatis is much larger than that of hibernate.

2. The po mapped by database fields is essentially different from the Po mapped by hibernate object ing. The po of the former is flat, the po of hibernate can express three-dimensional object inheritance, aggregation, and other relationships.

3. Powerful hibernate functions, good database independence, and strong o/R ing capabilities.

4. Compared with ibatis, Hibernate is more widely used. Its documentation, product integrity, and version development speed must be more powerful.

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.