Package org.datanucleus.state
Class LifeCycleState
java.lang.Object
org.datanucleus.state.LifeCycleState
Base Class representing the life cycle state. Implemented for individual states.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Detached-Cleanstatic final int
Detached-Dirtystatic final int
Hollowstatic final int
illegal stateprotected boolean
protected boolean
protected boolean
protected boolean
protected boolean
static final int
Persistent-Cleanstatic final int
Persistent-Deletedstatic final int
Persistent-Dirtystatic final int
Persistent-Newstatic final int
Persistent-New-Deletedstatic final int
Persistent-NonTransactionalstatic final int
Persistent-NonTransactionalDirtyprotected int
static final int
Transaction-Cleanstatic final int
Transaction-Dirtystatic final int
total number of statesstatic final int
transient -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final LifeCycleState
changeState
(DNStateManager sm, int newStateType) Utility to change state to a new state.protected final LifeCycleState
changeTransientState
(DNStateManager sm, int newStateType) Utility to change state to a new state.final boolean
Return whether the object is deleted.final boolean
isDirty()
Return whether the object is dirty, ie has been changed (created, updated, deleted) in this Tx.final boolean
isNew()
Return whether the object was newly created.final boolean
Return whether the object is persistent.final boolean
Return whether the object is transactional.final int
Returns the type of the life cycle stateabstract String
toString()
Method to return a string version of this object.Method to transition to persistent-clean.transitionBegin
(DNStateManager sm, Transaction tx) Method to transition to transaction begin state.Method to transition to commit state.Method to transition to delete persistent state.Method to transition to detached-clean.Method to transition to evict state.Method to transition to nontransactional state.Method to transition to persistent state.transitionMakeTransactional
(DNStateManager sm, boolean refreshFields) Method to transition to transactional state.transitionMakeTransient
(DNStateManager sm, boolean useFetchPlan, boolean detachAllOnCommit) Method to transition to transient state.transitionReadField
(DNStateManager sm, boolean isLoaded) Method to transition to read-field state.Method to transition to refresh state.transitionRetrieve
(DNStateManager sm, boolean fgOnly) Method to transition to retrieve state.transitionRetrieve
(DNStateManager sm, FetchPlan fetchPlan) Method to transition to retrieve state.Method to transition to rollback state.Method to transition when serialised.Method to transition to write-field state.
-
Field Details
-
TRANSIENT
public static final int TRANSIENTtransient- See Also:
-
P_NEW
public static final int P_NEWPersistent-New- See Also:
-
P_CLEAN
public static final int P_CLEANPersistent-Clean- See Also:
-
P_DIRTY
public static final int P_DIRTYPersistent-Dirty- See Also:
-
HOLLOW
public static final int HOLLOWHollow- See Also:
-
T_CLEAN
public static final int T_CLEANTransaction-Clean- See Also:
-
T_DIRTY
public static final int T_DIRTYTransaction-Dirty- See Also:
-
P_NEW_DELETED
public static final int P_NEW_DELETEDPersistent-New-Deleted- See Also:
-
P_DELETED
public static final int P_DELETEDPersistent-Deleted- See Also:
-
P_NONTRANS
public static final int P_NONTRANSPersistent-NonTransactional- See Also:
-
P_NONTRANS_DIRTY
public static final int P_NONTRANS_DIRTYPersistent-NonTransactionalDirty- See Also:
-
DETACHED_CLEAN
public static final int DETACHED_CLEANDetached-Clean- See Also:
-
DETACHED_DIRTY
public static final int DETACHED_DIRTYDetached-Dirty- See Also:
-
TOTAL
public static final int TOTALtotal number of states- See Also:
-
ILLEGAL_STATE
public static final int ILLEGAL_STATEillegal state- See Also:
-
isDirty
protected boolean isDirty -
isNew
protected boolean isNew -
isDeleted
protected boolean isDeleted -
isTransactional
protected boolean isTransactional -
isPersistent
protected boolean isPersistent -
stateType
protected int stateType
-
-
Constructor Details
-
LifeCycleState
public LifeCycleState()
-
-
Method Details
-
stateType
public final int stateType()Returns the type of the life cycle state- Returns:
- the type of this life cycle state
-
changeState
Utility to change state to a new state.- Parameters:
sm
- StateManagernewStateType
- The new state- Returns:
- new LifeCycle state.
-
changeTransientState
Utility to change state to a new state.- Parameters:
sm
- StateManagernewStateType
- The new state- Returns:
- new LifeCycle state.
-
transitionMakePersistent
Method to transition to persistent state.- Parameters:
sm
- StateManager.- Returns:
- new LifeCycle state.
-
transitionDeletePersistent
Method to transition to delete persistent state.- Parameters:
sm
- StateManager.- Returns:
- new LifeCycle state.
-
transitionMakeTransactional
Method to transition to transactional state.- Parameters:
sm
- StateManager.refreshFields
- Whether to refresh loaded fields- Returns:
- new LifeCycle state.
-
transitionMakeNontransactional
Method to transition to nontransactional state.- Parameters:
sm
- StateManager.- Returns:
- new LifeCycle state.
-
transitionMakeTransient
public LifeCycleState transitionMakeTransient(DNStateManager sm, boolean useFetchPlan, boolean detachAllOnCommit) Method to transition to transient state.- Parameters:
sm
- StateManager.useFetchPlan
- to make transient the fields in the fetch plandetachAllOnCommit
- Whether to detach on commit- Returns:
- new LifeCycle state.
-
transitionBegin
Method to transition to transaction begin state.- Parameters:
sm
- StateManager.tx
- Transaction.- Returns:
- new LifeCycle state.
-
transitionCommit
Method to transition to commit state.- Parameters:
sm
- StateManager.tx
- the Transaction been committed.- Returns:
- new LifeCycle state.
-
transitionRollback
Method to transition to rollback state.- Parameters:
sm
- StateManager.tx
- Transaction.- Returns:
- new LifeCycle state.
-
transitionRefresh
Method to transition to refresh state.- Parameters:
sm
- StateManager.- Returns:
- new LifeCycle state.
-
transitionEvict
Method to transition to evict state.- Parameters:
sm
- StateManager.- Returns:
- new LifeCycle state.
-
transitionReadField
Method to transition to read-field state.- Parameters:
sm
- StateManager.isLoaded
- if the field was previously loaded- Returns:
- new LifeCycle state.
-
transitionWriteField
Method to transition to write-field state.- Parameters:
sm
- StateManager.- Returns:
- new LifeCycle state.
-
transitionRetrieve
Method to transition to retrieve state.- Parameters:
sm
- StateManager.fgOnly
- only retrieve the current fetch group fields- Returns:
- new LifeCycle state.
-
transitionRetrieve
Method to transition to retrieve state.- Parameters:
sm
- StateManager.fetchPlan
- the fetch plan to load fields- Returns:
- new LifeCycle state.
-
transitionDetach
Method to transition to detached-clean.- Parameters:
sm
- StateManager.- Returns:
- new LifeCycle state.
-
transitionAttach
Method to transition to persistent-clean.- Parameters:
sm
- StateManager.- Returns:
- new LifeCycle state.
-
transitionSerialize
Method to transition when serialised.- Parameters:
sm
- StateManager- Returns:
- The new LifeCycle state
-
isDirty
public final boolean isDirty()Return whether the object is dirty, ie has been changed (created, updated, deleted) in this Tx.- Returns:
- Whether the object is dirty.
-
isNew
public final boolean isNew()Return whether the object was newly created.- Returns:
- Whether the object is new.
-
isDeleted
public final boolean isDeleted()Return whether the object is deleted.- Returns:
- Whether the object is deleted.
-
isTransactional
public final boolean isTransactional()Return whether the object is transactional.- Returns:
- Whether the object is transactional.
-
isPersistent
public final boolean isPersistent()Return whether the object is persistent.- Returns:
- Whether the object is persistent.
-
toString
Method to return a string version of this object.
-