Hibernate Annotations

Hibernate @Immutable: Read-Only Entities and Collections

Hibernate’s @Immutable annotation stops UPDATE statements for an entity, blocks changes to a collection and, since Hibernate 7, fails HQL update queries by default. We compare it with updatable = false, read-only queries, @Subselect and records.

Hibernate @NaturalId: Natural Ids, Lookups and Caching

Map a natural id such as a license plate with Hibernate’s @NaturalId, load entities with em.find(…, KeyType.NATURAL), handle mutable and composite natural ids, and cache lookups with @NaturalIdCache, with the SQL and statement counts from Hibernate 7.4.

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.