While i started my knowledge sessions for myself to learn something apart of my work, have picked up iBATIS, its understanding and when to use it.
When brushing up the fundamentals of iBatis and its pros and cons ... first question popped up to my mind was 'Why iBatis ... Why not any other framework?'. So my track automatically took a side turn for comparing the iBATIS with other existing persistence frameworks.
So now i am gonna talk about three know persistence frameworks
1. iBATIS
2, Hibernate
3. JPA
About iBATIS :1. iBATIS is a persistence framework that provides the benefits of SQL but avoids the complexity of JDBC.
2. iBATIS encourages the direct use of SQL and ensures that all the benefits of SQL are not overridden by the framework itself.
3. Simplicity is iBATIS's greatest advantage, as it provides a simple mapping and API layer that can be used to build data-access code.
4. iBATIS enables the data model and the object model to be independent of each other.
When to use iBATIS :1. iBATIS is best used when you need complete control of the SQL.
2. It is also useful when the SQL queries need to be fine-tuned.
When Not to Use iBATIS:1. iBATIS should not be used when you have full control over both the application and the database design, because in such cases the application could be modified to suit the database, or vice versa.
2. iBATIS is also inappropriate for non-relational databases, because such databases do not support transactions and other key features that iBATIS uses.
About Hibernate :1. Hibernate is an open source, lightweight object-relational mapping solution.
2. Hibernate includes a very powerful query language called Hibernate Query Language, or HQL.
3. HQL is very similar to SQL, and also defines some additional conventions.
4. HQL also supports many advanced features of pagination and dynamic profiling that SQL has never supported.
5. HQL does not require any explicit joins when working with multiple tables.
6. Hibernate makes object-relational mapping simple by mapping the metadata in an XML file that defines the table in the database that needs to be mapped to a particular class.
When to use Hibernate :1. Hibernate is best used to leverage end-to-end OR mapping. It provides a complete ORM solution, but leaves you control over queries.
2. Hibernate is the best option for object-oriented programmers who are less familiar with SQL.
About Java Persistence API :1. The Java Persistence API is the standard object-relational mapping and persistence management interface for the Java EE 5 platform. As part of the EJB 3 specification effort, it is supported by all major Java vendors.
2. JPA is a POJO-based standard persistence model for ORM. It is part of the EJB 3 specification and replaces entity beans.
3. JPA uses metadata annotations and/or XML descriptor files to configure the mapping between Java objects in the application domain and tables in the relational database.
4. Defines an SQL-like query language, JPQL (Java Persistence Query Language), which is different from EJB-QL (EJB Query Language), the language used by entity beans.
When to use JPA :1. JPA should be used when you need a standard Java-based persistence solution.
2. JPA supports inheritance and polymorphism, both features of object-oriented programming.
When not to use JPA :1. Caching, which is not clearly defined in JPA but is well supported by Hibernate.
2. JPA is defined to work with relational databases only.
3. If your persistence solution needs to be extended to other types of data stores, like XML databases, then JPA is not the answer to your persistence problem.