iBATIS maps Java Objects to the results of SQL Queries, whereas Hibernate maps Java Objects directly to database tables, traditional Object-Relational Mapping. The benefits of Hibernate are that it automatically generates all the SQL for your and the cache invalidation can be more fine grained. iBATIS is more flexible especially if you are a strong SQL query writer. You have control over exactly how the SQL queries are written.
When determining which framework to use, I think one thing to remember is that there is an optimal relational model to support every object model. There is not an optimal object model to represent every relational model. Use hibernate if you have mostly standard queries(CRUD, Find by Criteria, etc.) and if you are designing your object model first, then a relational model to support the object model. If you are working with a legacy system or a schema designed by a DBA, iBATIS often makes a better choice. If you try to shoehorn hibernate into a relational model created by a DBA who could care less about objects and thinks in terms of tables, columns, relationships and record sets, then you will get along better with your DBA if you use iBATIS, especially if the model is complex and may entail queries with outer joins and nested subqueries. You can tell them "All of the SQL statements used by my application are stored in these XML files outside of my Java code, so you can easily review them". DBAs like that. Of course, you might be lucky enough to work with a DBA that is familar with OO design and ORM tools like hibernate, in which case hibernate might make a better choice.
Bottom line, in my experience, compared to Hibernate, iBATIS is more flexible, has a shorter learning curve, but can take more time to develop and maintain, since you have to write all your queries and if your object model changes you have to go through all your queries and make sure to make all the necessary changes to reflect the changes in your object model. I must admint though that I am biased because I have more experience with iBATIS. As I gain more experience with Hibernate, I could be singing a different tune.
1 則留言:
Just to add, hibernate is quite powerful and can handle multiple databases easily.
On the other hand, iBatis is very simple and very small learning curve, it also provide caching,lazy loading and other solutions.
iBatis in 10 minutes at Expert Developer Zone
Regards
Free Blog Service Network
Help Developers
Free Blog Service Network
張貼留言