Transitions between states in Hibernate 3
Different persistence operations in Hibernate can cause changes in the state of the object
As shown in the following illustration:
Objects built with the New keyword are transient states.
1. Transient state transitions to persistent state using the Session object's Save () or Saveorupdate () method to hold the object, the state of the object is converted from the transient state to the persisted state using the get () or load () of the Session object After a method gets an object, the state of the object is persisted state 2, the persisted state transitions to the instantaneous state of the Delete () method that executes the session object, and the object is changed from the original persistent state to the instantaneous state, so the object is not associated with any database data 3, The persistent state becomes Free State executes the evict (), clear (), close () method of the Session object, and the object is changed from the original persistent state to the Free State. 4, the Free State is converted to a persistent state to regain the session object, execute the Session object's update () or Saveorupdate () method, from the Free State to a persistent state, the object is again associated with the session. 5, the Free State transitions to the instantaneous state execution session of the Delete () method, the object has a free state into a transient state, the transient state or the Free State of the object is no longer referenced by other objects, the Java virtual machine is processed by the garbage collection mechanism