EntityState (enum)

Enumerates the state of an entity.

API

EntityState.java
enum EntityState {
  NOT_PERSISTABLE     (1)
  PERSISTABLE_ATTACHED     (2)
  PERSISTABLE_DETACHED     (3)
  PERSISTABLE_REMOVED     (4)
  PERSISTABLE_ATTACHED_NO_OID     (5)
  PERSISTABLE_DETACHED_WITH_OID     (6)
  boolean isPersistable()     (7)
  boolean isAttached()     (8)
  boolean isDetached()     (9)
  boolean isRemoved()     (10)
  boolean isAttachedNoOid()     (11)
  boolean isDetachedCannotReattach()
  boolean isAttachedOrRemoved()     (12)
  boolean isSpecicalJpaDetachedWithOid()     (13)
  boolean hasOid()
}
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 PERSISTABLE_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 PERSISTABLE_DETACHED

Object with this state is an entity but that is detached from a persistence session, in other words changes to the entity will not be flushed back to the database.

4 PERSISTABLE_REMOVED

Object with this state is an entity that has been removed from the database. Objects in this state may no longer be interacted with.

5 PERSISTABLE_ATTACHED_NO_OID

Is attached, has no OID yet. On pre-store.

6 PERSISTABLE_DETACHED_WITH_OID

JPA specific. Is detached, but has an OID.

7 isPersistable()

Object is an entity so is potentially persistable ot the database.

8 isAttached()

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.

9 isDetached()

Object with this state is an entity but that is detached from a persistence session, in other words changes to the entity will not be flushed back to the database.

10 isRemoved()

Object with this state is an entity that has been removed from the database. Objects in this state may no longer be interacted with.

11 isAttachedNoOid()
12 isAttachedOrRemoved()

deprecated:

not supported by JPA

13 isSpecicalJpaDetachedWithOid()

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).

PERSISTABLE_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.

PERSISTABLE_DETACHED

Object with this state is an entity but that is detached from a persistence session, in other words changes to the entity will not be flushed back to the database.

PERSISTABLE_REMOVED

Object with this state is an entity that has been removed from the database. Objects in this state may no longer be interacted with.

PERSISTABLE_ATTACHED_NO_OID

Is attached, has no OID yet. On pre-store.

PERSISTABLE_DETACHED_WITH_OID

JPA specific. Is detached, but has an OID.

isPersistable()

Object is an entity so is potentially persistable ot the database.

isAttached()

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.

isDetached()

Object with this state is an entity but that is detached from a persistence session, in other words changes to the entity will not be flushed back to the database.

isRemoved()

Object with this state is an entity that has been removed from the database. Objects in this state may no longer be interacted with.

Only supported by JDO. Will always return false with JPA.

isAttachedNoOid()

isAttachedOrRemoved()

deprecated:

not supported by JPA

isSpecicalJpaDetachedWithOid()