Hibernate 5 Features

In this article we are discussing Hibernate 5 Features. Hibernate 5 ORM fully supports new API's of JDK 8.

Hibernate 5 Features

Hibernate 5 ORM Features

Hibernate 5 is the major release of Hibernate framework, which provides the support for JDK 8 and Special database. In this article we are going to discuss all these features of Hibernate ORM 5.

In this tutorial series we will teach you Hibernate 5 with articles, tips and example codes. We have also provides you the necessary video tutorials of Hibernate 5 to explains the source code and examples projects.

RedHat is the company developing the Hibernate framework, Hibernate 5 was released on 20th August, 2015 with many new features and updated API. This release of Hibernate 5 perhaps a major release.

Let's see the features of Hibernate ORM 5:

Bootstrap

New Bootstrap comes with release of Hibernate ORM. New bootstrap mechanism of the Hibernate SessionFactory has been introduced with many features. Although method of creating SessionFactory used in Hibernate 4 is still compatible.

Modularity

Hibernate 5 supports following:

  • Wildfly
  • OSGi - The OSGi stands for Open Services Gateway initiative, which is an specification for dynamic, modularized system. Hibernate 5 supports OSGi which provides the capability of installing, activating, deactivating, and uninstalling during runtime, without requiring a system restart.

Why modularize?

  • Extensions
  • ORM Integration

Java 8 Support

Support of Java 8 in Hibernate 5 is one of the most important changes and it provides the support for Java 8 Date and Time API. To include this feature in your project you have to add hibernate-java8.jar file into your project.

If you are using maven then include following dependency:

<dependency>
	<groupId>org.hibernate</groupId>
	<artifactId>hibernate-java8</artifactId>
	<version>5.1.0.Final</version>
</dependency>

New Types

  • Date and Time API

Here are the new classes introduced:

DATE: java.time.LocalDate

TIME: java.time.LocalTime, java.time.OffsetTime

TIMESTAMP: java.time.Instant, java.time.LocalDateTime, java.time.OffsetDateTime and java.time.ZoneDateTime

Java 5, 6 and 7

  • Generics
  • AutoCloseable

Bytecode Augmentation

It comes with following features:

  • Smarter change detection
  • Better Maven and Gradle support
  • Enhanced Dirty checking
  • Bidirectional relationship management

AttributeConverter

Hibernate 5 also supports AttributeConverter:

  • Enums without @Enumerated
  • Invoked on null values
  • Hibernate Envers integration
  • @ElementCollection
  • @MayKey
  • @GeneratedValue(strategy=AUTO)
    UUID, custom strategy
  • Naming strategy
    physical and implicit

Hibernate Search

Hibernate 5 comes with support for full-text search through Lucene 5. So, developers can use the new features of Lucene full-text search engine in their applications.

Full-text Search support:

  • Lucene 5
  • Item level queries
  • Cluster - It supports Master/slave cluster

New Features of Hibernate 5

New features of Hibernate 5 are:

  • Lucene 5
  • Significant performance improvements
  • ElasticSearch backend

Hibernate OGM(Object/Grid Mapper)

This is another major feature of Hibernate 5 as through OGM it provides the ability of persistence to the NoSQL Database. In BigData environment Hibernate 5 can be used to interact with the NoSQL Databases such as Redis, Cassandra and others.

Hibernate provides the JPA(Java Persistence) support for NoSQL databases. It supports:

  • MongoDB(Fongo)
  • Infinispan
  • Neo4J(remote and embedded)
  • Redis
  • EhCache
  • Cassandra
  • CouchDB

Hibernate Envers

The Envers project of Hibernate enables the developer to audit the persistent classes in the application. The aim of the Envers project is to provide the ability to developers for auditing of persistent classes.

Developers will be able to use the Envers feature in application by just adding @Audited annotation in the persistence class. The Envers project will create a table for each entity which is being audited. This table hold the audit history of the changes which is made to the entity. It also allows the developer to query the historical data with ease.

In this we have discussed the features of Hibernate 5 ORM which comes with major features and also support for NoSQL databases through OGM. Check all the Hibernate 5 tutorials.