Identifier as Object - The earlier versions of Hibernate required that all identifier types
implement Serializable, Hibernate 6.0 has removed this restriction as identifiers can be any
Object. This change affects many API and SPI methods previously defined using Serializable.
@IdGeneratorType: With this release, you can use the @IdGeneratorType annotation for better
type-safe way to define custom generators for identifier generation.
Implicit Identifier Sequence and Table Name: The method by which Hibernate determines
implicit names for sequences and tables associated with identifier generation has been modified
in Hibernate 6.0, This may affect the user migrating applications. In this release, Hibernate
creates a sequence per entity hierarchy instead of a single sequence hibernate_sequence by
default.
Defaults for implicit sequence generators: Implicit sequences, like the hibernate_sequence
earlier now adhere to the default value of the JPA @SequenceGenerator annotation, which
means that the sequences have an allocation size of 50.
Type system: As Hibernate 6.0 is a major release, another important change was to modify
Hibernate’s mapping annotations and make them more type-safe. This feature was decided to
be provided in this release as type-related contracts were already changing to implement the
read-by-position changes.
Query: A lot of changes have been introduced in the functionality for Query. Query features
such as moving to a dedicated tree structure to model HQL and Criteria queries, improving the
implementations for bulk SQM DML statements like insert, update, and delete, as well as
changing the behavior of the hibernate.criteria.copy_tree property, and the inclusion of pass-
through tokens have been introduced in this release.
Signature change of the #onSave method: The signature of the #onSave method has been
changed from boolean onSave(Object entity, Serializable id, Object[] state, String[]
propertyNames, Type[] types) to boolean onSave(Object entity, Object id, Object[] state,
String[] propertyNames, Type[] types) to accomadate the change of expected identifier type
from Serializable to Object.
Fetch circularity determination: Previous versions of Hibernate determined fetches using a
depth-first approach, which occasionally led to odd "circularity" determination. Starting with
Hibernate 6.0, now fetch determination is performed using a width first approach.
Restructuring of org.hibernate.loader: The contents of the loader.collection package were
restructured into loader.ast.spi and loader.ast.internal as well as adapted to the SQM API.
Restructuring of the SQL package: The contents of sql.ordering were moved to
metamodel.mapping.ordering.ast.
Deprecation of hbm.xml mappings: Legacy hbm.xml mapping format is deprecated and will no
longer supported beyond 6.x.
Lazy association adherance: Prior to Hibernate 6.0, lazy associations that used fetch="join" or
@Fetch(FetchMode.JOIN) were considered eager when loaded by id i.e. through
Session#get/EntityManager#find, even though for queries the association was treated as lazy.
Starting with Hibernate 6.0, the laziness of such associations is properly respected, regardless
of the fetch mechanism. Backwards compatibility can be achieved by specifying lazy="false" or
@ManyToOne(fetch = EAGER)/@OneToOne(fetch = EAGER)/@OneToMany(fetch =
EAGER)/@ManyToMany(fetch = EAGER).
Change of behavior for hbm.xml <return-join/>: As per Hibernate 6.0, a <return-join/>` cause
an association to be fetched, rather than adding a selection item.