Hibernate Entity bean (Pojo) class having 3 states
Whenever pojo class object created then it will be in the Transient state.
Transient state Object does not represent any row of the database, It means not associated with any Session object or no relation with the database its just an normal object.
Transient state Object does not effect on the database table even if we modify the data of pojo class object.
Transient state Object may be made persistent by calling save(), persist() or saveOrUpdate().
Having the relation with the database, associated with a unique Session object
When an object is associated with a unique session, it’s in persistent state. it represent one row of the database, if the object is in persistentstate.
Any instance returned by a get() or load() method is persistent state object.
product p =(product)session.get(product.class);
if we want to move an object from persistent to detached state, we need to do either closing that session or need to clear the cache of the session.
When an object is previously persistent but not associated with any session, it’s in detachedstate.
Detached instances may be made persistent by calling update(), saveOrUpdate(), lock() or replicate().
The state of a transient or detached instance may also be made persistent as a new persistent instance by calling merge().