UmurInan
Hibernate Topic

Hibernate

Hibernate makes the easy database work easier and the hard database work much harder. These posts cover the n+1 problem, ddl-auto pitfalls, the queries Hibernate writes that you would never write by hand, and how equals/hashCode go wrong on entities.

Backend

Posted on May 19, 2026

Open Session in View Is Spring Boot's Quietest Footgun

Spring Boot ships with Open Session in View on by default. Lazy loading from controllers, hidden N+1s, JDBC connections pinned for the whole HTTP request.

Read more
Backend

Posted on May 12, 2026

Your Equals and HashCode Are Wrong

Hibernate entities in a Set stop being findable after you persist them. equals and hashCode based on a null id change the moment the database assigns a value.

Read more
Backend

Posted on May 10, 2026

Hibernate's ddl-auto Is Not a Migration Tool

ddl-auto: update silently adds columns and never drops them. What it does to your schema, why it fails on renames, and how to safely replace it with Flyway.

Read more
Backend

Posted on Apr 24, 2026

The Hibernate Query You Didn't Write

Hibernate writes SQL you never see. Three repository lines execute a 2,100-character query that is usually worse than anything you would have written by hand.

Read more
Backend

Posted on Apr 12, 2026

@Transactional Is Not Magic

@Transactional looks simple until you hit self-invocation, wrong exception types, or silent failures on private methods. Here's what it actually does.

Read more
Backend

Posted on May 19, 2026 advanced

Spring Data Derived Queries: Crossing Boundaries

Nested traversal in Spring Data derived queries: the underscore rule, the distinct-join trap, the same-collection trap, projections, EntityGraph, streams.

Read more
Backend

Posted on May 19, 2026 advanced

Spring Data Derived Queries: The Single-Entity Toolkit

Spring Data writes JPQL from your method names. The full single-entity keyword set: equality, comparison, string ops, null, In, OrderBy, Top, Pageable, countBy.

Read more
Backend

Posted on Apr 12, 2026 intermediate

@Transactional Demystified: Every Attribute With Working Tests

Every @Transactional attribute explained with real working code: propagation, rollbackFor, readOnly, timeout, and isolation, each proved by a failing test.

Read more
Database

Posted on Apr 10, 2026 intermediate

Optimistic vs Pessimistic Locking in JPA

Two JPA strategies for preventing the lost update problem. @Version for optimistic locking, SELECT FOR UPDATE for pessimistic. Real SQL output, working tests.

Read more
Database

Posted on Apr 7, 2026 intermediate

The N+1 Problem: All Four Fetch Strategies Explained

A hands-on walkthrough of all four Hibernate fetch strategies with real query counts. Each fix is verified by a test that proves the N+1 problem first.

Read more