Skip to main content

Hibernate

Spring Data JPA 3 to 4 Migration Guide: Query Derivation Changes, the hibernate-processor Coordinate Swap, and Value-Objects

A beginner-to-advanced guide to migrating the repository layer from Spring Data JPA 3 to 4 on Spring Boot 4.1: the hibernate-jpamodelgen → hibernate-processor coordinate swap and the silent metamodel failure it causes, why derived queries now generate JPQL instead of CriteriaQuery (and the getSingleResultOrNull edge case), records as @Embeddable value objects and projection targets, JSpecify nullability, the refined Specification API, and the removed config that breaks your build — all mapped to real code and errors on a Spring Boot 4.1 app.

Hibernate 5 to 6 to 7 Migration Guide: The Breaking Changes and the Silent Ones

I have now taken three codebases through the Hibernate 5 → 6 → 7 path, and the same pattern repeated each time: the compile errors are the easy part, and the silent behaviour changes — query result types, ID generation, fetch semantics — are what reach production. This guide walks the migration in two deliberate hops (5→6, then 6→7), with the exact errors you will see at each stage and how to fix them. Do not attempt 5→7 in one jump; the diagnostics assume you pass through 6.

10 AI Prompts for Hibernate and JPA

10 copy-paste AI prompts for Hibernate and JPA development. Covers entity relationship design, fixing LazyInitializationException, writing JPQL queries, generating Flyway migrations, second-level cache, bulk operations, soft delete, auditing with @EntityListeners, Criteria API Specifications, and full entity model reviews.

Hibernate 7 get() vs getReference(): Four Calls, Four Outcomes

session.get() and session.getReference() look interchangeable at a glance, but the difference isn't "eager vs lazy" -- it's what you're telling Hibernate you need. This piece runs four calls against Hibernate 7.4.1.Final, builds the full same-session matrix, and pins down exactly where the proxy identity contract breaks -- including one same-session result that the usual L1-cache explanation gets wrong.

Hibernate 7 merge() vs refresh(): Which One Fails Loudly?

merge() and refresh() get described as opposite directions of the same tool -- one pushes, one pulls. Run them against a real @Version-ed entity and that framing misses the actual question: which one fails loudly when the state it's holding is stale? Three named experiments against Hibernate 7.4.1.Final, including a result that overturned the article's own original assumption.

Hibernate 7 Batch Inserts: How to Prove Batching Is Working

Setting hibernate.jdbc.batch_size is not the same as verifying batching happens. Two nearly identical entities, one GenerationType difference, and Hibernate's own statistics show a 30-vs-4 prepared-statement gap -- then two sweeps (allocationSize, batch_size) run the numbers instead of predicting them, including one off-by-one that reproduced across two separate full-suite runs.