Entity lifecycle
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
name the four states and the moves between them.
Planned topics
- Transient: new object, not known to JPA.
- Managed: tracked by the persistence context; changes are saved at flush.
- Detached: was managed, but the context closed (usually after the transaction).
- Removed: marked for deletion at flush.
persistmakes transient managed;mergecopies a detached state into a managed instance;removeschedules deletion.
Draft outline details
Demonstration
a diagram: new → transient → persist → managed → remove → removed; managed → context closes → detached → merge → managed.
Check your understanding
Are changes to a detached entity saved automatically?
Show answer
No.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.