Comparison between ibatis and Hibernate

Source: Internet
Author: User

 

In my initial selection, I planned to select hibernate. During the study, I found that ibatis
After analysis and comparison, I chose ibatis. Now I have used ibatis to complete a small and medium-sized project. This
I am very satisfied with the performance, maintainability, and scalability of the project.

In this process, I also constantly discuss with people who have used or are using hibernate. And I myself
We are constantly following up on the development of hibernate.

In the end, I came to the conclusion that ibatis was the correct choice, and the more I liked it.

Of course, my understanding of Hibernate is still very limited, so here are some ideas about hibernate.
Point errors hope to be corrected by the hibernate experts.

1. ibatis is easy to master. Take the document and read it in half a day or two days.
  Hibernate may take more than three times to master.
  
2. ibatis is easier to optimize SQL.

  Everyone should have a consensus on this. In addition, the SQL statement generated by Hibernate is too ugly. Identification
  Some friends mentioned that SQL is not very important. I would like to emphasize my experience, general system performance
  The bottlenecks are all in the database. Therefore, this is an important advantage of ibatis.
  
3. ibatis can be fine-grained for optimization.

  3.1 for example, if I have a table with several or dozens of fields, I need to update
      Ibatis is very simple. Execute an SQL
      Update table_a set column_1 = # column_1 # Where id = # ID #
      However, it is troublesome to use hibernate. By default, Hibernate will update all fields.
      Of course, I remember that hibernate has an option to control only storing modified fields, but I am not sure
      Determines the negative effect of this function.
      
  3.2 I need to list part of the content of a table. When using ibatis, the advantage here is that it can be less
    The database reads a lot of data, saving traffic
      Select ID, name from table_with_a_lot_of_column where...

    3.2.1 In general
    Hibernate Selects all fields. For example, there is a table with eight fields,
    There are two relatively large fields, varchar (255)/text. In the above scenario, why should I take him
    Are you sure you want?

    3.2.2 If Hibernate is used, you cannot set the two unnecessary fields as lazy load because
    In many cases, the entire domain object needs to be loaded at one time. At this time, we can see
    Ibatis benefits

    3.2.3 another solution for Hibernate is to generate JavaBean/MAP/object [] (thanks
    Leelun/cjmm), but this may produce a large number of redundant classes. MAP/object [] Method
    It should be good. I prefer this method.
      
  3.3 If I want to update a record (an object), if Hibernate is used
    Such as select, and then update. This is two SQL statements for the database. While ibatis
    You only need an update SQL statement. Reduces one interaction with the database, for performance
    Improvement is very important.

4. Development
  4.1 development efficiency, I think the two should be similar
  4.2 In terms of maintainability, I think ibatis is better. Because ibatis SQL is saved
      In a separate file. In some cases, Hibernate may save SQL/hql in Java code.

5. Operation Efficiency
  5.1 without considering the cache, ibatis should be faster or much faster than hibernate, which may vary according to the actual situation.

      
Of course, ibatis also has many disadvantages.
1. The support for different database types is not good. If the system you want to develop is to be transplanted between data pairs, it may be better to use hibernate.
2. The default cache support is not good, but the hibernate cache support is not very good and complicated. Especially for applications with large concurrency. Therefore, I prefer to manage the cache myself.

 

Original post address: http://moonsee.iteye.com/blog/253226

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.