spring-boot-hibernate
Installation
SKILL.md
Hibernate ORM Mapping and Runtime Behavior
Hibernate is a state machine with a SQL generator attached. Most production surprises come from ignoring the state machine, not from a missing annotation. Decide mapping deliberately, keep the persistence context small, and let the schema live in migrations.
When to use
- Choosing between
@EmbeddedIdand a surrogate key, or between@ElementCollectionand a JSONB column. - Fixing
LazyInitializationException,MultipleBagFetchException, or a cascade that writes rows nobody expected. - Setting up batch inserts, ordered updates, and the identifier strategy that unblocks batching.
- Proving or eliminating an N+1 with Hibernate statistics, understanding the four entity states and dirty checking cost, and deciding whether a
StatelessSessionor the caches help.
When not to use
- SQL dialect, index selection, or plan analysis: hand off to
spring-boot-postgresql. - Repository interfaces, Specifications, or pagination API design: hand off to
spring-boot-data-jpa. - Migration files, baselines, or schema history: hand off to
spring-boot-flyway. - End-to-end latency, caching layers, and throughput remediation: hand off to
spring-boot-query-optimization.