Hibernate and iBatis are both Database Persistence Frameworks.
Here’s the difference of both, and which to choose for appropriate usage.
Hibernate – Hibernate is seen as larger and has more functionality, and seems to be more advanced in Cache. It offers a close to Java oriented coding where there is less bother on SQL. Downside of large frameworks is the learning curve to learn something new aside from the SQL.
1.) Database connectivity is already encapsulated, just edit a config file and add the Database location/URL , username and password.
2.) There is a need to create an xml file and POJO ( with getters and setters ) that maps to a database table. Only one xml file and one POJO for each corresponding table.
3.) Create a Java Code, then use the hibernate methods to access the database. In a hibernate funtion, you may use SQL , HQL or none, as it depends on the method used.
MyBatis – ( previously called iBatis ) is much more simplified and lightweight compared to Hibernate. Also best to use if there is an already existing live ( complex ) database, since it has the ability to map it easily because of its simple approach. iBatis still uses SQL and does not encapsulate it unlike Hibernate.
1.) Database connectivity is already encapsulated, just edit a config file and add the Database location/URL , username and password, which is quite similar to Hibernate.
2.) Create a DTO which is a POJO that similary corresponds to a database table or a structured dataset.
3.) All SQL commands and queries are written in the xml mapper file. Then each entry of a SQL set command is mapped to the DTO java file. There can be multiple mapper files and DTO files, as needed.
4.) To use the SQL commands, use the DTO java file and use the methods with the corresponding parameters as described in the xml mapper file.
For a more Java and Object Oriented approach, Hibernate provides this. If comfortable to use SQL, and less on Java coding, iBatis can do it.
See more from this site: