EntityState (enum)
Enumerates the state of an entity.
API
enum EntityState {
NOT_PERSISTABLE (1)
ATTACHED (2)
ATTACHED_NO_OID (3)
DETACHED (4)
HOLLOW (5)
TRANSIENT_OR_REMOVED (6)
REMOVED (7)
boolean isPersistable() (8)
boolean isAttached() (9)
boolean isAttachedNoOid() (10)
boolean isDetached() (11)
boolean isHollow() (12)
boolean isTransientOrRemoved() (13)
boolean isRemoved() (14)
boolean isAttachedOrRemoved()
}
1 | NOT_PERSISTABLE
Object with this state is not an entity (for example it might be a view model, value type or a domain service). |
2 | ATTACHED
Object with this state is an entity that is attached to a persistence session, in other words changes to the entity will be flushed back to the database. |
3 | ATTACHED_NO_OID
Is attached, has no OID yet. On pre-store. |
4 | DETACHED
Is detached, hence (per definition) has an OID. |
5 | HOLLOW
JDO specificObject with this state is an entity that no longer attached to a persistence session and cannot be re-attached. In other words: changes to the entity will not be tracked nor flushed back to the database. |
6 | TRANSIENT_OR_REMOVED
Object with this state is an entity that is transient or has been removed from the database. Objects in this state may no longer be interacted with. |
7 | REMOVED
JDO specificNot supported by JPA. (Cannot distinguish between TRANSIENT and REMOVED.) |
8 | isPersistable()
Object is an entity, hence is persistable to the database. |
9 | isAttached() |
10 | isAttachedNoOid() |
11 | isDetached() |
12 | isHollow() |
13 | isTransientOrRemoved() |
14 | isRemoved() |
Members
NOT_PERSISTABLE
Object with this state is not an entity (for example it might be a view model, value type or a domain service).
ATTACHED
Object with this state is an entity that is attached to a persistence session, in other words changes to the entity will be flushed back to the database.
DETACHED
Is detached, hence (per definition) has an OID.
Supported by both JDO and JPA. However, historically never used by the framework for JDO.
HOLLOW
JDO specificObject with this state is an entity that no longer attached to a persistence session and cannot be re-attached. In other words: changes to the entity will not be tracked nor flushed back to the database.
JDO distinguishes between DETACHED and HOLLOW, by virtue of javax.jdo.option.detachAllOnCommit=false .
(Unfortunately, we have not found a way to recover OIDs from hollow entities, as used for serialization post commit. We have instead implemented a workaround using the DnStateManagerForHollow
class).