intermediate~4h
Entity Lifecycle — Persist, Merge, Detach, Remove & Proxies
Every entity is always in exactly one of four states — knowing which one, and how persist/merge/detach/remove transition between them, prevents the majority of real-world Hibernate bugs, LazyInitializationException chief among them.
Learning objectives
- Name the four entity lifecycle states and the operations that transition between them.
- Explain why merge() returns a new object rather than mutating the one passed into it.
- Explain what a proxy is and why accessing one after its persistence context closes throws LazyInitializationException.
This is a Pro chapter
Sign in, then upgrade to Pro or Power to unlock this and the full Spring Ecosystem Mastery library.
Entity Lifecycle — Persist, Merge, Detach, Remove & Proxies