JPA Entity States and the Persistence Context

JPA Entity States and the Persistence Context A lifecycle diagram generated by Archify. 01 / Managed path 02 / Detached + Removal 03 / Gone Transient · new Order() · Managed path 01 Transient new Order() Managed · dirty checking · Managed path 02 Managed dirty checking Flushed · SQL sent · Managed path 03 Flushed SQL sent Commit? · or rollback · Managed path 04 Commit? or rollback Durable · row in database · Managed path 05 Durable row in database Detached · context closed · Detached Detached context closed Removed · DELETE at flush · Removal Removed DELETE at flush Deleted · row gone · Gone Deleted row gone close Legend start active state waiting decision terminal success failure / exit neutral

Unit of work

  • • Changes to managed entities are saved automatically

Lazy loading

  • • Needs an open persistence context
© 2026 Samir Kumar Sahoo. All rights reserved.