Hibernate and iBatis both are open source Object Relational Mapping(ORM) tools available in the industry. Use of each of these tools depends on the context you are using them. Here are few criteria we can keep in our mind while choosing one over other.
1. Way of working
Hibernate maps your Java POJO objects to the Database tables where as iBatis maps the ResultSet from JDBC API to your POJO Objets. So in case of iBatis you may need to pass your parameters to the DAO class in a map object which can be passed to the Statement.
2. XML mappings
Hibernate and iBatis both use XML based mapping and are quite intuitive to implement. Tools are available to create and edit these file. e.g. Abator for iBatis and Hibernate tools.
Within in the java persistence there is no one size, fits all solution. So, in this case Hibernate which is a de facto standard is used in lot of places.
1. Way of working
Hibernate maps your Java POJO objects to the Database tables where as iBatis maps the ResultSet from JDBC API to your POJO Objets. So in case of iBatis you may need to pass your parameters to the DAO class in a map object which can be passed to the Statement.
2. XML mappings
Hibernate and iBatis both use XML based mapping and are quite intuitive to implement. Tools are available to create and edit these file. e.g. Abator for iBatis and Hibernate tools.
3. Project from Scratch with new Database or Existing Database Hibernate works well when you control the data model, iBATIS works well when you need to integrate with an existing database. In the projects where the Project is being developed from scratch and developer has to come up with database design along with the Java object model then Hibernate is a good option as it becomes easy to develop and mappings becomes intuitive. Hibernate also provides ways to generate database from mappings files itself. Which may reduce your deployment script generation efforts.
Using iBatis for a project which is developed from scratch is also very simple and does not involve lot of efforts.
4. Data centric project
A project which has database intensive operations to be done and needs to utilize lot of existing implementations which are available in Database layer then iBatis provides easier way to leverage on it. Hibernate also provides way to handle such situations but it gets complex as your application becomes more and more complex. The hibernate developer need to start understanding lot of complex things to accomplish it.
5. Hibernate Query Language (HQL) vs Structured Query Language (SQL)
Its another choice which you may want to take in case you application involves lot of complex database intensive operations then in Hibernate you may want to go for Hibernate Query Language (HQL) which will have following aspects
- Learning curve for developers
- You will not be able to see the actual SQL because Hibernate generates it internally, though there is a way to see what is being generated but you lose the direct control over it.
- Abstraction of SQL makes it difficult for the developers visualize what is happening at that layer.
Where as in case of iBatis you have same SQL available to you in the XML mapping file and you can play around with it as you wish, which gives you lot of freedom to tune in performance of queries.
6. Simple Applications
In case your application is simple with not lot of complex data processing then Hibernate could be a decent option. Also if a developer does not like SQL much then it could be a good option too.
7. SPRING Integration
Hibernate and iBatis both have good support from SPRING framework so it should not be a problem to chose one of them.