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



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

Answer / 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

More Hibernate Interview Questions

What are the extension interfaces that are there in hibernate?

1 Answers  


Can we use hibernate with cassandra?

1 Answers  


What are the identified limitation of hibernate?

1 Answers  


What is entitymanager persist?

1 Answers  


What is hibernate and spring java?

1 Answers  


What is indexing in hibernate?

1 Answers  


What is the architecture of hibernate?

1 Answers  


What is transient instance state in hibernate?

1 Answers  


What is persistent state?

1 Answers  


How to check hibernate version in spring boot?

1 Answers  


Is orphanremoval true?

1 Answers  


What are the benefits of orm and hibernate?

1 Answers  


Categories