javax.jdo.spi.StateManager - JDO interface

javax.jdo.spi
Interface StateManager

This interface is the point of contact between managed instances of PersistenceCapable classes and the JDO implementation. It contains the methods used by PersistenceCapable instances to delegate behavior to the JDO implementation.

Each managed PersistenceCapable instance contains a reference to a StateManager. A StateManager might manage one or multiple instances of PersistenceCapable instances, at the choice of the implementation.

Since:
JDO 1.0
boolean getBooleanField( PersistenceCapable pc, int field, boolean currentValue)
Return the value for the field.
Return the value for the field.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
Returns:
the new value for the field
Since:
JDO 1.0
byte getByteField( PersistenceCapable pc, int field, byte currentValue)
Return the value for the field.
Return the value for the field.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
Returns:
the new value for the field
Since:
JDO 1.0
char getCharField( PersistenceCapable pc, int field, char currentValue)
Return the value for the field.
Return the value for the field.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
Returns:
the new value for the field
Since:
JDO 1.0
double getDoubleField( PersistenceCapable pc, int field, double currentValue)
Return the value for the field.
Return the value for the field.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
Returns:
the new value for the field
Since:
JDO 1.0
float getFloatField( PersistenceCapable pc, int field, float currentValue)
Return the value for the field.
Return the value for the field.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
Returns:
the new value for the field
Since:
JDO 1.0
int getIntField( PersistenceCapable pc, int field, int currentValue)
Return the value for the field.
Return the value for the field.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
Returns:
the new value for the field
Since:
JDO 1.0
long getLongField( PersistenceCapable pc, int field, long currentValue)
Return the value for the field.
Return the value for the field.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
Returns:
the new value for the field
Since:
JDO 1.0
Object getObjectField( PersistenceCapable pc, int field, Object currentValue)
Return the value for the field.
Return the value for the field.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
Returns:
the new value for the field
Since:
JDO 1.0
Return the object representing the JDO identity of the calling instance.
Return the object representing the JDO identity of the calling instance. If the JDO identity is being changed in the current transaction, this method returns the identity as of the beginning of the transaction.
Parameters:
pc - the calling PersistenceCapable instance
Returns:
the object representing the JDO identity of the calling instance
Since:
JDO 1.0
Return the PersistenceManager that owns this instance.
Return the PersistenceManager that owns this instance.
Parameters:
pc - the calling PersistenceCapable instance
Returns:
the PersistenceManager that owns this instance
Since:
JDO 1.0
short getShortField( PersistenceCapable pc, int field, short currentValue)
Return the value for the field.
Return the value for the field.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
Returns:
the new value for the field
Since:
JDO 1.0
String getStringField( PersistenceCapable pc, int field, String currentValue)
Return the value for the field.
Return the value for the field.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
Returns:
the new value for the field
Since:
JDO 1.0
Return the object representing the JDO identity of the calling instance.
Return the object representing the JDO identity of the calling instance. If the JDO identity is being changed in the current transaction, this method returns the current identity as changed in the transaction.
Parameters:
pc - the calling PersistenceCapable instance
Returns:
the object representing the JDO identity of the calling instance
Since:
JDO 1.0
Return the object representing the version of the calling instance.
Return the object representing the version of the calling instance.
Parameters:
pc - the calling PersistenceCapable instance
Returns:
the object representing the version of the calling instance
Since:
JDO 2.0
Tests whether this object has been deleted.
Tests whether this object has been deleted. Instances that have been deleted in the current transaction return true.

Transient instances return false.

Parameters:
pc - the calling PersistenceCapable instance
Returns:
true if this instance was deleted in the current transaction.
Since:
JDO 1.0
See Also:
PersistenceManager.deletePersistent(Object pc)
boolean isDirty( PersistenceCapable pc)
Tests whether this object is dirty.
Tests whether this object is dirty. Instances that have been modified, deleted, or newly made persistent in the current transaction return true.

Transient nontransactional instances return false.

Parameters:
pc - the calling PersistenceCapable instance
Returns:
true if this instance has been modified in the current transaction.
Since:
JDO 1.0
See Also:
PersistenceCapable.jdoMakeDirty(String fieldName)
boolean isLoaded( PersistenceCapable pc, int field)
Return true if the field is cached in the calling instance.
Return true if the field is cached in the calling instance.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
Returns:
whether the field is cached in the calling instance
Since:
JDO 1.0
boolean isNew( PersistenceCapable pc)
Tests whether this object has been newly made persistent.
Tests whether this object has been newly made persistent. Instances that have been made persistent in the current transaction return true.

Transient instances return false.

Parameters:
pc - the calling PersistenceCapable instance
Returns:
true if this instance was made persistent in the current transaction.
Since:
JDO 1.0
See Also:
PersistenceManager.makePersistent(Object pc)
Tests whether this object is persistent.
Tests whether this object is persistent. Instances whose state is stored in the data store return true.

Transient instances return false.

Parameters:
pc - the calling PersistenceCapable instance
Returns:
true if this instance is persistent.
Since:
JDO 1.0
See Also:
PersistenceManager.makePersistent(Object pc)
Tests whether this object is transactional.
Tests whether this object is transactional. Instances that respect transaction boundaries return true. These instances include transient instances made transactional as a result of being the target of a makeTransactional method call; newly made persistent or deleted persistent instances; persistent instances read in data store transactions; and persistent instances modified in optimistic transactions.

Transient nontransactional instances return false.

Parameters:
pc - the calling PersistenceCapable instance
Returns:
true if this instance is transactional.
Since:
JDO 1.0
void makeDirty( PersistenceCapable pc, String fieldName)
Mark the associated PersistenceCapable field dirty.
Mark the associated PersistenceCapable field dirty.

The StateManager will make a copy of the field so it can be restored if needed later, and then mark the field as modified in the current transaction.

Parameters:
pc - the calling PersistenceCapable instance
fieldName - the name of the field
Since:
JDO 1.0
Guarantee that the serializable transactional and persistent fields are loaded into the instance.
Guarantee that the serializable transactional and persistent fields are loaded into the instance. This method is called by the generated jdoPreSerialize method prior to serialization of the instance.
Parameters:
pc - the calling PersistenceCapable instance
Since:
JDO 1.0
void providedBooleanField( PersistenceCapable pc, int field, boolean currentValue)
The value of the field requested to be provided to the StateManager.
The value of the field requested to be provided to the StateManager.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
Since:
JDO 1.0
void providedByteField( PersistenceCapable pc, int field, byte currentValue)
The value of the field requested to be provided to the StateManager.
The value of the field requested to be provided to the StateManager.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
Since:
JDO 1.0
void providedCharField( PersistenceCapable pc, int field, char currentValue)
The value of the field requested to be provided to the StateManager.
The value of the field requested to be provided to the StateManager.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
Since:
JDO 1.0
void providedDoubleField( PersistenceCapable pc, int field, double currentValue)
The value of the field requested to be provided to the StateManager.
The value of the field requested to be provided to the StateManager.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
Since:
JDO 1.0
void providedFloatField( PersistenceCapable pc, int field, float currentValue)
The value of the field requested to be provided to the StateManager.
The value of the field requested to be provided to the StateManager.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
Since:
JDO 1.0
void providedIntField( PersistenceCapable pc, int field, int currentValue)
The value of the field requested to be provided to the StateManager.
The value of the field requested to be provided to the StateManager.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
Since:
JDO 1.0
void providedLongField( PersistenceCapable pc, int field, long currentValue)
The value of the field requested to be provided to the StateManager.
The value of the field requested to be provided to the StateManager.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
Since:
JDO 1.0
void providedObjectField( PersistenceCapable pc, int field, Object currentValue)
The value of the field requested to be provided to the StateManager.
The value of the field requested to be provided to the StateManager.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
Since:
JDO 1.0
void providedShortField( PersistenceCapable pc, int field, short currentValue)
The value of the field requested to be provided to the StateManager.
The value of the field requested to be provided to the StateManager.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
Since:
JDO 1.0
void providedStringField( PersistenceCapable pc, int field, String currentValue)
The value of the field requested to be provided to the StateManager.
The value of the field requested to be provided to the StateManager.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
Since:
JDO 1.0
boolean replacingBooleanField( PersistenceCapable pc, int field)
The replacement value of the field in the calling instance.
The replacement value of the field in the calling instance.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
Returns:
the new value for the field
Since:
JDO 1.0
byte replacingByteField( PersistenceCapable pc, int field)
The replacement value of the field in the calling instance.
The replacement value of the field in the calling instance.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
Returns:
the new value for the field
Since:
JDO 1.0
char replacingCharField( PersistenceCapable pc, int field)
The replacement value of the field in the calling instance.
The replacement value of the field in the calling instance.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
Returns:
the new value for the field
Since:
JDO 1.0
Object[] replacingDetachedState( Detachable pc, Object[] state)
The replacement value of the detached state in the calling instance.
The replacement value of the detached state in the calling instance.
Parameters:
pc - the calling Detachable instance
state - the current value of the detached state
Returns:
the replacement value for the detached state
Since:
JDO 2.0
double replacingDoubleField( PersistenceCapable pc, int field)
The replacement value of the field in the calling instance.
The replacement value of the field in the calling instance.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
Returns:
the new value for the field
Since:
JDO 1.0
The owning StateManager uses this method to supply the value of the flags to the PersistenceCapable instance.
The owning StateManager uses this method to supply the value of the flags to the PersistenceCapable instance.
Parameters:
pc - the calling PersistenceCapable instance
Returns:
the value of jdoFlags to be stored in the PersistenceCapable instance
Since:
JDO 1.0
float replacingFloatField( PersistenceCapable pc, int field)
The replacement value of the field in the calling instance.
The replacement value of the field in the calling instance.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
Returns:
the new value for the field
Since:
JDO 1.0
int replacingIntField( PersistenceCapable pc, int field)
The replacement value of the field in the calling instance.
The replacement value of the field in the calling instance.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
Returns:
the new value for the field
Since:
JDO 1.0
long replacingLongField( PersistenceCapable pc, int field)
The replacement value of the field in the calling instance.
The replacement value of the field in the calling instance.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
Returns:
the new value for the field
Since:
JDO 1.0
Object replacingObjectField( PersistenceCapable pc, int field)
The replacement value of the field in the calling instance.
The replacement value of the field in the calling instance.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
Returns:
the new value for the field
Since:
JDO 1.0
short replacingShortField( PersistenceCapable pc, int field)
The replacement value of the field in the calling instance.
The replacement value of the field in the calling instance.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
Returns:
the new value for the field
Since:
JDO 1.0
Replace the current value of jdoStateManager.
Replace the current value of jdoStateManager.

This method is called by the PersistenceCapable whenever jdoReplaceStateManager is called and there is already an owning StateManager. This is a security precaution to ensure that the owning StateManager is the only source of any change to its reference in the PersistenceCapable.

Parameters:
pc - the calling PersistenceCapable instance
sm - the proposed new value for the jdoStateManager
Returns:
the new value for the jdoStateManager
Since:
JDO 1.0
String replacingStringField( PersistenceCapable pc, int field)
The replacement value of the field in the calling instance.
The replacement value of the field in the calling instance.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
Returns:
the new value for the field
Since:
JDO 1.0
void setBooleanField( PersistenceCapable pc, int field, boolean currentValue, boolean newValue)
Mark the field as modified by the user.
Mark the field as modified by the user.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
newValue - the proposed new value of the field
Since:
JDO 1.0
void setByteField( PersistenceCapable pc, int field, byte currentValue, byte newValue)
Mark the field as modified by the user.
Mark the field as modified by the user.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
newValue - the proposed new value of the field
Since:
JDO 1.0
void setCharField( PersistenceCapable pc, int field, char currentValue, char newValue)
Mark the field as modified by the user.
Mark the field as modified by the user.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
newValue - the proposed new value of the field
Since:
JDO 1.0
void setDoubleField( PersistenceCapable pc, int field, double currentValue, double newValue)
Mark the field as modified by the user.
Mark the field as modified by the user.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
newValue - the proposed new value of the field
Since:
JDO 1.0
void setFloatField( PersistenceCapable pc, int field, float currentValue, float newValue)
Mark the field as modified by the user.
Mark the field as modified by the user.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
newValue - the proposed new value of the field
Since:
JDO 1.0
void setIntField( PersistenceCapable pc, int field, int currentValue, int newValue)
Mark the field as modified by the user.
Mark the field as modified by the user.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
newValue - the proposed new value of the field
Since:
JDO 1.0
void setLongField( PersistenceCapable pc, int field, long currentValue, long newValue)
Mark the field as modified by the user.
Mark the field as modified by the user.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
newValue - the proposed new value of the field
Since:
JDO 1.0
void setObjectField( PersistenceCapable pc, int field, Object currentValue, Object newValue)
Mark the field as modified by the user.
Mark the field as modified by the user.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
newValue - the proposed new value of the field
Since:
JDO 1.0
void setShortField( PersistenceCapable pc, int field, short currentValue, short newValue)
Mark the field as modified by the user.
Mark the field as modified by the user.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
newValue - the proposed new value of the field
Since:
JDO 1.0
void setStringField( PersistenceCapable pc, int field, String currentValue, String newValue)
Mark the field as modified by the user.
Mark the field as modified by the user.
Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
newValue - the proposed new value of the field
Since:
JDO 1.0

This documentation page is derived (with some adjustments) from the JDO 2.2 API
and is available under the terms of the Apache License, v. 2.0.