Card 07/ 07
All 7 cards
RecapDifficulty: Advanced1 min
What This Topic Established
An entity is always in one of four states — transient, managed, detached, removed — and persist, find, detach, merge and remove are what move it between them, verified with real contains() checks at each step.
persist()'s INSERT runs immediately under GenerationType.IDENTITY and is deferred to flush under GenerationType.SEQUENCE — verified against real statement counts, not the commonly simplified single rule. A change to a detached entity reaches nothing until merge() copies it onto a new managed instance; refresh() reloads one entity from the database, discarding local changes, while clear() detaches everything without touching the database at all.