Hibernate ( keep English for hibernation ) is an open source persistence and ORM framework for Java. For the. NET a ported version called NHibernate is available.
Hibernates main task is the Object - Relational Mapping (OR - Mapping, short ORM). This enables ordinary objects with attributes and methods ( referred to in the Java section POJOs ) to be stored in a relational database, and to generate data sets of respective objects in turn. Relationships between objects are mapped to corresponding database relations.
In addition, Hibernate provides mechanisms to assure compatibility with various databases. The required to access the database SQL statements are not explicitly programmed in SQL, but generated by Hibernate, depending on the SQL dialect of the database used.
Application side can hibernate in Java applications and servlet engines are used or integrated into an application server.
The query the persisted objects is carried out via the SQL-like query language Hibernate Query Language ( HQL ), using SQL statements or object- oriented by the Hibernate Criteria API. The queries are translated depending on the database used by JDBC in the corresponding SQL dialect. Hibernate provides for all current relational database management systems appropriate settings, new SQL dialects can be added by the user.
Hibernate allows transparent persistence of Plain Old Java Objects ( POJOs ). Only a parameterless constructor must be given. Since Hibernate accesses the attributes of classes using Reflection, no public access functions are necessary.
The mapping from Java classes to database tables via an XML file (mapping file) or accomplished with Java Annotation. When using XML files for both the matching Java classes as well as the database tables can be generated by Hibernate tools in the use of annotation latter is also possible.
Hibernate supports object references ( 1:1 relations ) and ( typed ) Java Collections ( 1: N and N: M relations), as well as reflexive relations on the class of its own. When loading objects related objects can be optionally loaded as immediately ( eager loading ) or only when they are really needed ( lazy loading ). Lazy loading is the default option for all 1: N and N: M relationships, but only works within the same transaction or session. Hibernate can also be configured so that operations such as saving or deleting also cascade over relations and thus the referential integrity is maintained.
Hibernate supports all three types of object- relational mapping inheritance relationships (Table per inheritance hierarchy table per subclass and table-per- concrete class ), in addition, also Implicit polymorphism as a special form of table per concrete class.
Also allows an optional Hibernate mapping from Java types to those supported by the database SQL types. This Java Enums means, for example, to map similar to normal Integer Properties, or distribute individual properties across multiple table columns.
Probably the most important Hibernate classes are SessionFactory, Session and Transaction. SessionFactory loads the configuration and mappings, and is usually created only once per application. Session is the link between the Java application and Hibernate services, and provides methods for insert, update, delete and query operations. Transaction represents JDBC and JTA transactions. Nested transactions are not supported.
In addition to the core functionality of Hibernate still includes the following sub-projects:
History and distribution
Hibernate was developed in 2001 by a team of Java developers with Gavin King. The company JBoss, Inc., maker of the free Java application server wildfly presented, later some of the key Hibernate developers in order to accelerate the integration of Hibernate in the Application Server.
The 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), Fetch profiles (V 3.5 ), a reorganization of the Hibernate module (V 3.5) and Maven support (V 3.3).
The current major version of Hibernate is 4.x. She brought in particular a number of improvements in logging and integrator as well as refactorings, which make working with Hibernate. In addition, Hibernate 4.0 introduced multi-tenancy with one or more database instances and database schemas. Since version 4.3, Hibernate implements the JPA 2.1 specification.
The development of Hibernate 5.0 is currently in progress. In Hibernate 5.0, the metamodel is redefined and the clients ability to be further expanded.
Hibernate is used according to the homepage of tens of thousands of Java projects worldwide. Approximately 25,000 developers are registered with the Hibernate forums. Hibernate is downloaded on average about 3,000 times a day.