Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What's the difference between iBATIS and Hibernate?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you what is the difference between iBATIS and Hibernate, I believe that most people still do not understand, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The choice between iBATIS and Hibernate is a problem that programmers have to choose. I intended to choose Hibernate in the initial selection. I found iBATIS in the process of research. After analysis and comparison, I chose iBATIS. Now I have completed a small and medium-sized project using iBATIS. I am very satisfied with this project in terms of performance, maintainability and scalability.

In the process, I have also constantly discussed with people who have used or are using Hibernate. And I am also constantly following up the development of Hibernate. In the end, I concluded that iBATIS made the right choice, and the more I used it, the more I liked it. Of course, my understanding of Hibernate is still very limited, so I hope that some of the mistakes in the views on Hibernate here can be corrected by Hibernate experts.

1.iBATIS is easy to master.

Read the document for half a day or two and you can master it. Hibernate may take more than three times as long to master.

2. IBATIS is easier to optimize sql.

We should all have a consensus on this. In addition, the sql generated by Hibernate is really ugly. In view of the fact that some friends mentioned that sql is not very important. I would like to emphasize my experience here that the bottleneck of general system performance is on the database. So this is a very important advantage of iBATIS.

3.iBATIS can be optimized with fine granularity.

For example, I have a table that has several or dozens of fields. I need to update one of the fields. IBATIS is very simple. It is troublesome to execute a sql UPDATE TABLE_A SET column_1=#column_1# WHERE id=#id# but use Hibernate. By default, Hibernate updates all the fields. Of course I remember that Hibernate has an option to save only modified fields, but I'm not sure about the negative effects of this feature.

3.2I need to list some of the contents of a table. When using iBATIS, the advantage is that you can read a lot of data from the database less, saving SELECT ID, NAME FROM TABLE_WITH_A_LOT_OF_COLUMN WHERE...

3.2.1 General situation

Hibernate will select all the fields. For example, there is a table above that has eight fields, including one or two larger fields, varchar / text. Why did I pick them out in the above scene?

3.2.2 with Hibernate, you can't set these two unwanted fields to lazy load, because there are a lot of places where you need to load the entire domain object at once. At this time, the benefits of iBATIS can be shown.

3.2.3 another solution for Hibernate is to generate javabean/map/object [] (thanks to leelun/cjmm), but this may generate a lot of excess class. The map/object [] approach should be good, and I prefer it.

3.3.If I need to update a record (an object), if I use Hibernate, I need to select the object now and then update it. These are two sql for the database. IBATIS only needs a sql of update. Reducing one interaction with the database is very important for performance improvement.

4. Development aspect

4.1 in terms of development efficiency, I think the two should be about the same.

In terms of maintainability, I think iBATIS is better. Because the sql of iBATIS is saved in a separate file. And Hibernate may be saved in java code in some cases

Sql/hql .

5. Operation efficiency

5.1 regardless of cache, iBATIS should be faster or much faster than Hibernate (depending on the actual situation).

Of course, iBATIS also has some big shortcomings.

1. The support of different database types is not good, if the system you are developing is to be migrated between Chinese data, it may be better to use Hibernate.

two。 The default cache support is not good, but Hibernate's cache support is not very good and complex. Especially for applications with large concurrency. So I prefer to manage cache myself.

These are all the contents of this article entitled "what's the difference between iBATIS and Hibernate". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report