Detached State

Detached State

If we perform the operations like close(), clear(), evict() etc. over the Session object then POJO object will come from Persistence State to Detached State.

A detached instance is an object that has been persistent, but its Session has been closed. The reference to the object is still valid, of course, and the detached instance might even be modified in this state.

In Detached State, Hibernate Software is not aware about POJO object and it will not provide synchronization between POJO object and database table record.

In Detached State, POJO object is representing valid record in database table, but modifications on POJO object are not reflected to that record.

In Detached State, if we perform operations like save() , update(), saveOrUpdate() etc over the persistence object after getting Session back then POJO object will transfer from Detached State to Persistence State again.

If we keep POJO object in Detached State for long time then POJO object is eligible for Garbage Collection, where Garbage Collector will destroy that object.

Detached State
Scroll to top