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.
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 BackendYour 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 BackendHibernate'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 BackendThe 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@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 BackendSpring 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 BackendSpring 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@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 DatabaseOptimistic 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 DatabaseThe 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