Hibernate (Framework)

from Wikipedia, the free encyclopedia

Basic data

developer JBoss ( Red Hat )
Publishing year 2001
Current  version 5.4.19
( July 27, 2020 )
operating system cross-platform
programming language Java
category ORM
License LGPL

Hibernate ( English for hibernate ) is an open-source - persistence - and ORM - Framework for Java . A ported version called NHibernate is available for .NET .

Hibernate's main task is the object-relational mapping (English OR mapping , ORM for short). This enables ordinary objects with attributes and methods (called Plain Old Java Objects or POJOs in the Java environment ) to be stored in relational databases and objects to be generated from corresponding data records. Relationships between objects are mapped to corresponding database relationships.

In addition, Hibernate offers mechanisms for compatibility with various databases. The SQL statements required for database access are not explicitly programmed in SQL , but are generated by Hibernate depending on the SQL dialect of the database used.

On the application side, Hibernate can be used in Java applications and servlet engines or integrated into an application server .


The query of the persistent objects can be done using the SQL-like query language Hibernate Query Language (HQL), using SQL statements or object-oriented using the Hibernate Criteria API. Depending on the database used, the queries are translated into the corresponding SQL dialect using JDBC . Hibernate offers appropriate settings for all current relational database systems. New SQL dialects can be added by the user.

Object-relational mapping

Hibernate enables a transparent persistence of Plain Old Java Objects (POJOs) . Only a parameterless constructor must be given. Since Hibernate accesses the attributes of the classes by means of reflection , no public access functions are necessary.

The mapping of Java classes to database tables is done using an XML file (mapping file) or with Java annotation. When using XML files, the Hibernate tools can be used to generate both the appropriate Java classes and the database tables; when using annotations, only the latter is possible.

Hibernate supports object references ( 1: 1 relations ) and (typed) Java collections (1: N and N: M relations), as well as reflexive relations to its own class. When objects are loaded, related objects can either be loaded immediately (eager loading) or only when they are really needed (lazy loading) . Lazy loading is the standard option for all 1: N and N: M relationships, but only works within the same transaction or session. Hibernate can also be configured in such a way that operations such as saving or deleting can also be cascaded via relations and thus the referential integrity is preserved.

Hibernate supports all three types of object-relational mapping of inheritance relationships ( table per inheritance hierarchy , table per subclass and table per specific class ), as well as implicit polymorphism as a special form of table per specific class .

Hibernate also enables the optional mapping of Java types to the SQL types supported by the database. This z. B. enables Java enums to be mapped analogously to normal integer properties, or individual properties to be distributed over several table columns .

"SessionFactory", "Session" and "Transaction"

SessionFactoryloads the configuration and the images and is normally only generated once per application. Sessionis the link between the Java application and the Hibernate services and offers methods for insert, update, delete and query operations. Transactionmaps JDBC and JTA transactions. Nested transactions are not supported.

Further functionalities

In addition to the core functionality, Hibernate also includes the following sub-projects:

Hibernate annotations
OR mapping using annotations
Hibernate EntityManager
Implementation of the Java Persistence API interface
Hibernate Shards
Access to horizontally partitioned database tables
Hibernate Validator
Definition of data integrity and validation rules in JavaBean classes using annotations
Hibernate Search
Transparent creation of a full text index and full text search with Lucene
Hibernate tools
Development tools for Eclipse and Ant


NHibernate is the counterpart to Hibernate for the .NET Framework . The current version (as of February 14, 2020) is version 5.2.7 from January 2020. From version 5.1, .NET Core is also supported.

NHibernate is more than a pure C # port; it uses the additional possibilities of C # such as B. Properties. It can be used as an alternative to the Entity Framework .


There are also a number of sub-projects for NHibernate. With Fluent NHibernate, the creation of xml files for the mapping can be avoided. Automapping makes it possible to dispense with listing individual attributes again. Fluent NHibernate makes extensive use of lambda expressions for configuration.

History and Distribution of Hibernate

Hibernate was developed in 2001 by a team of Java developers under Gavin King. The company JBoss, Inc. , maker of the free Java application server wildfly , hired later some key Hibernate developers to promote the integration of Hibernate in the Application Server.

Version 3.x brought functionalities such as session-based filters, JDK 5.0 annotations and generics , DB schema validation (V 3.1), JPA 1.0 (V 3.2) and 2.0 (V 3.5), and fetch profiles (V 3.5 ), a reorganization of the Hibernate modules (V 3.5) and Maven support (V 3.3).

In particular, Hibernate 4.x brought various improvements in logging and integrator as well as refactorings , which make working with Hibernate easier. In addition, Hibernate 4.0 brought multi- tenancy with one or more database instances or database schemas. Starting with version 4.3, Hibernate implements the JPA 2.1 specification.

The current version 5.x of Hibernate redefines the metamodel and further expands the multi-client capability.

According to the homepage, Hibernate is used by tens of thousands of Java projects worldwide. About 25,000 developers are registered on the Hibernate forums. Hibernate is downloaded around 3,000 times a day on average.

See also


  • Christian Bauer, Gavin King: Java-Persistence with Hibernate , Hanser Verlag, 2007, ISBN 978-3-446-40941-5
  • Richard Oates, Thomas Langer, Stefan Wille, Torsten Lueckow, Gerald Bachlmayr: Spring & Hibernate. A practical introduction , Hanser Verlag, 2006, ISBN 978-3-446-40457-1
  • Sebastian Hennebrüder: Hibernate, the practical book for developers , Galileo Press, 2007, ISBN 978-3-89842-635-0
  • Dave Minter, Jeff Linwood, Reinhard Engel: Introduction to Hibernate , Mitp-Verlag, 2007, ISBN 978-3826617942
  • Bernd Müller, Harald Wehr: Java Persistence API with Hibernate , Addison-Wesley, 2007, ISBN 978-3827325372
  • Robert F. Beeger, Arno Haase, Stefan Roock, Sebastian Sanitz: Hibernate: Persistence in Java systems with Hibernate 3.2 and the Java Persistence API , Dpunkt Verlag, 2007, ISBN 978-3898644471
  • Markus Kehle, Hien Robert: Hibernate and the Java Persistence API , Developer. Press , 2006, ISBN 978-3935042963

Web links

Individual evidence

  1. in.relation.to .
  2. Supported databases
  3. ^ Gavin King, Christian Bauer, Max Rydahl Andersen, Emmanuel Bernard, Steve Ebersole: Inheritance mapping. (No longer available online.) In: Hibernate Community Documentation. Red Hat April 14, 2010; archived from the original on February 12, 2010 ; Retrieved on May 19, 2010 (English): "Hibernate supports the three basic inheritance mapping strategies: table per class hierarchy, table per subclass, table per concrete class. In addition, Hibernate supports a fourth, slightly different kind of polymorphism: implicit polymorphism “ Info: The archive link was inserted automatically and not yet checked. Please check the original and archive link according to the instructions and then remove this notice. @1@ 2Template: Webachiv / IABot / docs.jboss.org
  4. nhibernate.info
  5. releases of nhibernate-core. Retrieved February 14, 2020 .
  6. www.fluentnhibernate.org
  7. ^ Hibernate Road Map
  8. Multi-tenancy in Hibernate
  9. Hibernate Core 4.0 is final
  10. Hibernate ORM 4.3.0 Final Release
  11. ^ Hibernate Roadmap
  12. Product Evaluation FAQ ( Memento of the original from April 27, 2009 in the Internet Archive ) Info: The archive link was inserted automatically and has not yet been checked. Please check the original and archive link according to the instructions and then remove this notice. @1@ 2Template: Webachiv / IABot / www.hibernate.org