The core benefits of Hibernate are simplicity, flexibility, completeness, and performance.
- Simplicity and flexibility:
- Hibernate requires a single runtime configuration file and one mapping document for each application object to be persisted.
- To use some persistence frameworks, such as EJBs, your application becomes dependent on that framework. Hibernate doesn’t create this additional dependency. Persistent objects in your application don’t have to inherit from a Hibernate class or obey specific semantics.
- Unlike EJBs, Hibernate doesn’t require a special container in order to function.
- Hibernate requires a single runtime configuration file and one mapping document for each application object to be persisted.
- Completeness
- Hibernate supports the full range of object-oriented features, including inheritance, custom object types, and collections.Hibernate frees you to create a domain model without concern for persistence layer limitations.
- Provide HQL
- Performance
- Hibernate issues an update for an object only if its state has actually changed
- Lazy collections provide another performance enhancement.
- Selectively disable which associated objects are retrieved when the primary object is retrieved(this is accomplished by setting the outer-join property to false for the association or declared the Object as proxies).
- Object caching also plays a large role in improving application performance.
- Caching can be enabled for a persistent class or for a collection of persistent objects.
- Query results can also be cached, but doing so only benefits queries that run with the same parameters (Query caching doesn’t significantly benefit application performance, but the option is available for appropriate cases)