Step 4- States of objects in hibernate
Hibernate object states-
- When object is just created and has no primary key, the state is called transient.
- When session is opened and object is just saved in database [using save, saveOrUpdate, persist, merge etc method]
- or retrieved from the database [using get, load etc method]. This state is called persistent.
- When the session was closed, the state changes to detached.
- or evict() , clear() etc methods are applied, The object is detached from its session.