adspace


How does hibernate distinguish between transient (i.e. Newly instantiated) and detached objects?

Answer Posted / Avinash Tripathi

Hibernate distinguishes between transient and detached objects based on their association with a Hibernate Session.n
1. Transient Objects: These are newly instantiated objects that have no persistent identity and are not associated with any session.n
2. Detached Objects: Initially, these were persistent objects associated with a Hibernate Session but are no longer associated because the session was closed or evicted.nnHibernate uses a flag called 'identity' to distinguish between transient and persistent (managed) objects. When an object is saved in the database for the first time, its identity is set to true, indicating that it's now a managed object. If the object becomes detached, the identity flag remains true, but the object is no longer associated with any session.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is latest hibernate version?

493