- Tech know how online


Hibernate is a framework for mapping objects to relational databases for the Javaprogramming language - it is also called Object Relational Mapping Tool. Hibernate is implemented in the Java programming language and is freely available as open source at the link below. Hibernate uses the concept of reflection to determine so-called meta- information about the structure of objects and the underlying classes at runtime of a software, which is then mapped to the tables of a database.

Hibernate implements the Java Persistence API( JPA) - a standard API for object-relationalmappings - and provides additional functionality. This includes database queries using the Hibernate Query Language (HQL) and the programmatic ability to define queries using the Hibernate Criteria API. Hibernate can be integrated into a wide variety of software and system architectures such as rich client, client- server, Web applications, J2EE or Java Enterprise Edition (JEE). Hibernate was developed with support from JBoss Inc. and is also integrated into the JBoss application server. For the . NET platform, NHibernate is a ported version of Hibernate. This requires Fluent NHibernate and LINQ to NHibernate, which are available at the links below.

Object Relational Mapping (ORM) for structural mappings on relational databases

Object Relational Mapping( ORM) refers to a technique for mapping the objects of software created on the basis of object-oriented programming to the structures of a relational database. Incidentally, this technique has a high prevalence, since the use of purely object-oriented databases, OODB, has not yet become established in practice. Since relational formations cannot always be connected 1:1 with object-oriented structures, this is an approach for tools that support OR mapping. In addition to commercial tools such as Oracle Toplink, Hibernate is one of the best known and most developed persistence frameworks available as open source. Its use not only enables it to connect to most relational database systems, but also takes into account aspects such as cluster capability, caching and session management. Hibernate is characterized by both extensive tool support and high performance.

Since with Hibernate most available data bases can be used, the access to the respective data base is performant by the fact that Hibernate supports different data base dialects. The necessary information for accessing the specific database is collected in a separate configuration file, which is then loaded by Hibernate when the SessionFactory class is instantiated. The configuration file also compiles the names of the classes for whose instances persistence is then to be generated at runtime. Hibernate uses similar mechanisms as that with the likewise well-known Java Data Objects( JDO) the case is. For example, the type of ID generation or the hierarchy ofinheritance can be specified. Likewise Hibernate offers functions such as a performaten Second level cache or a transaction management similarly as with JDO. Beside the already mentioned class SessionFactory further Session and Transaction are central classes of the Frameworks Hibernate.

Hibernate for transient objects

The Hibernate sessions organize the handling of persistent objects and are therefore of central importance. Each access to a database is a session and thus connects the Java application to the database. The states of the business objects are managed and the session is also responsible for their persistence, loading as well as deletion. In order to change persistent data, transactions must be used. It makes sense to have a maximum of one transaction object created by a session. The support of nested transactions is not provided. As soon as several transactions are opened, these run completely isolated from each other. Each session has its own cache, which provides for the appropriate performance. Hibernate supports different implementations of transactions. With JDBC transactions the mechanism of the used database is used. Java Database Connectivity (JDBC) is part of the Java Development Kit( JDK) and allows access to relational databases. Alternatively, the transaction mechanism of the application server can be used with Java Transaction API( JTA).

For the query of databases there are different possibilities with the Hibernate Query Language (HQL) and with Querys as well as Criterias. The syntax of HQL is similar to that of SQL and the JDO query language JDOQL. In addition, the query is implemented using SQL statements and the Criterias API provides an object-oriented interface for use in a Java application. Since version 3 of Hibernate, it is not only possible to read data and objects, but these can also be modified or deleted with a query.

Compared to comparable persistence frameworks such as the commercial Oracle Toplink or iBATIS, which belongs more to the lightweight frameworks and is supported by Spring, Hibernate is characterized by an advanced state of development. In addition, good documentation and comprehensive tool support make implementing Hibernate much easier. Hibernate can be used directly by Java applications and servlet engines as well as integrated into an application server.

Englisch: hibernate
Updated at: 04.04.2020
#Words: 789
Links: framework, mapping, Java, programming language (PL), link
Translations: DE

All rights reserved DATACOM Buchverlag GmbH © 2024