case A: the session is not closed, and the tag object is in a constant state, and it (the tag object) is attached to the current session.
case B: here the session may be the same from the first transaction, you change the value of the tag object, which is in the Persistent state. Persistent state represents existence of object in permanent storage. There will be connection between the object in memory and in database through the identifier. Any change in either of these two will be reflected in other (when transaction is committed). Persistent state is dependent on session object. First, session has to be open (unclosed) Persistent state represents existence of object in permanent storage. There will be connection between the object in memory and in database through the identifier. Any change in either of these two will be reflected in other (when transaction is committed). Persistent state is dependent on session object. First, session has to be open (unclosed) [this is true in your case] , and second, the object has to be connected to the session. If either of these two is not true, then the object moves into either transient state or detached stage. , and second, the object has to be connected to the session. If either of these two is not true, then the object moves into either transient state or detached stage.
An object is in a disconnected state in the following case: Detached state arises when a persistent state object is not connected to a session object. No connection may be because the session itself is closed or the object is moved out of session. Detached state arises when a persistent state object is not connected to a session object. No connection may be because the session itself is closed or the object is moved out of session.
source share