1.

What Are The States Of An Object In Hibernate?

Answer»

The states of an object in hibernate are

  1. Transient
  2. Persistent
  3. Detached

Transient: The object is in the transient STATE if it is just CREATED but has no primary key (IDENTIFIER) and it is not associated with the session.
Persistent: The object is in the persistent state if the session is OPEN, and we just saved the instance in the database or retrieved the instance from the database.
Detached: The object is in the detached state if the session is closed. After detached state, the object comes to persistent state if we call lock() or update() method.

The states of an object in hibernate are

Transient: The object is in the transient state if it is just created but has no primary key (identifier) and it is not associated with the session.
Persistent: The object is in the persistent state if the session is open, and we just saved the instance in the database or retrieved the instance from the database.
Detached: The object is in the detached state if the session is closed. After detached state, the object comes to persistent state if we call lock() or update() method.



Discussion

No Comment Found