Reputation: 1529
I just saw that the 4th candidate got released for Hibernate 5. What's new in 5 compared to earlier versions?
Upvotes: 53
Views: 36411
Reputation: 153820
There's a long list of things that have been changed in Hibernate 5:
A new bootstrap API so we can bootstrap a JPA environment programmatically without the need of a persistence.xml
file.
Starting in 5.0 Hibernate Spatial is part of the Hibernate project so we can handle GIS data too.
The Java 8 Date and Time types are supported in domain model mappings. The mapping between the standard SQL Date/Time types and the supported Java 8 Date/Time class types looks as follows;
java.time.LocalDate
java.time.LocalTime
, java.time.OffsetTime
java.time.Instant
, java.time.LocalDateTime
, java.time.OffsetDateTime
and java.time.ZonedDateTime
The bytecode enhancement mechanism was redesigned from scratch, and Hibernate features both a Maven and a Gradle plugin. There are three main aspects which we can enhance with bytecode instrumentation:
Lazy initialization: Fields can be declared as LAZY
and they will be fetched only when being accessed for the first time.
Dirty checking: Entities are enhanced so that they can keep track of all the properties that get changed after being loaded in a Persistence Context.
Bidirectional associations: It's possible to synchronize both sides of a bidirectional association automatically, even if the developer only updates a single side.
Hibernate's native APIs (Session
, etc) have been updated to use generic types. No need to cast when fetching entities.
Hibernate 5.0 extends this to a broader set of types (e.g. UUID
).
Second-level cache by reference. This feature enables direct storage of entity references into the second level cache for immutable entities.
Starting with Hibernate 5.0, we have a completely new User Guide that was written from scratch.
Hibernate 5.1 adds the following features:
Hibernate 5.2 adds support for:
Query.stream()
Session
extends EntityManager
so you can get access to all JPA methods right from a Session
Timestamp
and Time
hibernate.connection.provider_disables_autocommit
resource-local transaction optimization.Upvotes: 46
Reputation: 8606
Some exciting features has been added/enhanced in Hibernate 5.x. Have a quick look.
Hibernate Search transparently indexes your objects and offers fast regular, full-text and geolocation search. Ease of use and easy clustering are core.
For more details on Hibernate Search view this.
Hibernate Validator comes with a handful of built-in validation rules like Email, Length, NotBlank etc.
Express validation rules in a standardized way using annotation-based constraints and benefit from transparent integration with a wide variety of frameworks.
For more details on Hibernate Validator view this.
Java 8 date/time data types (JSR 310) are supported and can be validated via @Past and @Future. Also Optional and JavaFX types are supported via an improved ValidatedValueUnwrapper.
Just released the first stable version.
New bootstrapping API - better determinism, better integration
A few other things:
Check Hibernate ORM Roadmap for more details.
Upvotes: 46