Introduction of Hibernate

  • Hibernate is a high-performance Object/Relational persistence and query service.
  • The most popular.
  • The most flexible and powerful Object/Relational solution on the market.
  • It provides data query and retrieval facilities that significantly reduce development time. Hibernate's design goal is to relieve the developer from 95% of common data persistence-related programming tasks by eliminating the need for manual, hand-crafted data processing using SQL and JDBC.
  • Hibernate is free software that is distributed under the GNU Lesser General Public License.
  • Hibernate solves object-relational impedance mismatch problem.
  • Hibernate was started in 2001 by Gavin King as an alternative to using EJB2-style entity beans.
Performance facts with Hibernate
Hibernate Query Performance

Note: The above figure shows the query performance between the Hibernate and JDBC. As Hibernate is a wrapper of JDBC, there is no such difference between performance.

Hibernate Insert Performance

Note:The above figure shows the insert performance between the Hibernate and JDBC, As you can see there is no difference between both performance.

Benefits of ORM/Hiberate

  • The SQL code / statements in the application can be eliminated without writing complex JDBC / Entity Bean code.
  • Distributed transaction can simply be performed by using ORM tools.
  • Hibernate is an open source ORM tool and a robust framework to perform ORMapping.
  • Without much of SQL knowledge, one can master Hibernate easily.
  • Caching objects
  • Executing SQL statements later, when needed
  • Never updating unmodified objects
  • Efficient Collection Handling
  • Rolling two updates into one
  • Updating only the modified columns
  • Outer join fetching
  • Lazy collection initialization
  • Lazy object initialization
  • Transparent persistence & retrieval of objects
  • Persistence of associations and collections
  • Guaranteed uniqueness of an object (within a session).
  • O-R mapping using ordinary JavaBeans
  • Can set attributes using private fields or private setter methods
  • Lazy instantiation of collections (configurable)
  • Polymorphic queries, object-oriented query language
  • Cascading persist & retrieve for associations, including collections and many-to-many
  • Transaction management with rollback
  • Can integrate with other container-provided services
Drawbacks of Using Hibernate
  • High Level abstraction obscuring what is happening under the hood.
  • Runs on top of JDBC.
  • Support for Hibernate on Internet is not sufficient.
  • For complex data, mapping from Object-to-tables and vise versa reduces performance and increases time of conversion.
  • Anybody wanting to maintain application using Hibernate will need to know Hibernate.
  • Hiberna te does not allow some type of queries which are supported by JDBC .