From BC$ MobileTV Wiki
Revision as of 20:28, 5 June 2022 by Bcmoney (Talk | contribs)

Jump to: navigation, search

Hibernate's goal is to relieve the developer from 95 percent of common data persistence related programming tasks, compared to manual coding with SQL and the JDBC API.

Hibernate Core for Java generates SQL for you, relieves you from manual JDBC result set handling and object conversion, and keeps your application portable to all SQL databases.[1].


Hibernate is also available in a .net variation called NHibernate: http://community.jboss.org/wiki/NHibernateforNET


Hibernate ORM overview


The Configuration can of Hibernate Object to Table mapping could be achieve by either of:

  1. XML file by the default name of "hibernate.cfg.xml" or some other name (through customized configuration settings) that can be passed in by default location (root of src folder), by file path, remote URL or as a Hibernate configuration object (pre-defined/loaded)
  2. Annotations such as @Entity and @Table that enable


Provides context to the session (pulls in configuration details to enable access to DB). Typically single SessionFactory per application (and lasts for full application lifecycle).


Acts as the persistence manager (central controller) that allows you to retrieve Objects to get data from the Hibernate cache. Any Transaction starts at the Session.


The Transaction is a single operation (such as Create=INSERT, Read=SELECT, UPDATE, DELETE) carried out within a given Session.


Entities can be associated with one Session (attached), and are implicitly attached to the Session from which they were obtained (explicitly attached when saving for the first time or after using an attach method; implicitly detached after Session closed). [2]


Hibernate Object/Grid Mapper (OGM) provides Java Persistence (JPA) support for NoSQL solutions. It reuses Hibernate ORM’s engine but persists entities into a NoSQL datastore instead of a Relational Database. Hibernate OGM's project page boasts: "Many NoSQL stores, one standard way to access them" and support for a "wide range of backends" via store-specific dialects. Currently, there is production-grade support for

  1. Key/Value: Infinispan, Ehcache
  2. Document: MongoDB
  3. Graph: Neo4j




External Links


  1. Hibernate project home: https://www.hibernate.org/
  2. Difference between Entity in JPA and Hibernate: http://stackoverflow.com/questions/955515/difference-between-jpa-entity-and-hibernate-entity
  3. Hibernate 3 <generator> element: http:///www.roseindia.net/hibernate/hibernateidgeneratorelement.shtml

See Also

Database | SQL | RDBMS | ORM | Java/JPA | ASP.NET/LINQ | PHP/PDO