public class TimestampLockingPolicy extends VersionLockingPolicy
Purpose: Used to allow a single version timestamp to be used for optimistic locking.
OptimisticLockingPolicy.LockOnChange| Modifier and Type | Field and Description |
|---|---|
static int |
LOCAL_TIME |
static int |
SERVER_TIME |
IN_CACHE, IN_OBJECT| Constructor and Description |
|---|
TimestampLockingPolicy()
PUBLIC:
Create a new TimestampLockingPolicy.
|
TimestampLockingPolicy(DatabaseField field)
INTERNAL:
Create a new TimestampLockingPolicy.
|
TimestampLockingPolicy(java.lang.String fieldName)
PUBLIC:
Create a new TimestampLockingPolicy.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareWriteLockValues(java.lang.Object value1,
java.lang.Object value2)
INTERNAL:
This method compares two writeLockValues.
|
java.lang.Object |
getBaseValue()
INTERNAL:
This is the base value that is older than all other values, it is used in the place of
null in some situations.
|
java.lang.Object |
getNewLockValue(ModifyQuery query)
INTERNAL:
Returns the new Timestamp value.
|
java.lang.Object |
getValueToPutInCache(AbstractRecord row,
AbstractSession session)
INTERNAL:
Return the value that should be stored in the identity map.
|
int |
getVersionDifference(java.lang.Object currentValue,
java.lang.Object domainObject,
java.lang.Object primaryKeys,
AbstractSession session)
INTERNAL:
Return the number of versions different between these objects.
|
Expression |
getWriteLockUpdateExpression(ExpressionBuilder builder,
AbstractSession session)
INTERNAL:
Return an expression that updates the write lock
|
java.lang.Object |
getWriteLockValue(java.lang.Object domainObject,
java.lang.Object primaryKey,
AbstractSession session)
INTERNAL:
This method will return the optimistic lock value for the object.
|
boolean |
isNewerVersion(AbstractRecord databaseRow,
java.lang.Object domainObject,
java.lang.Object primaryKey,
AbstractSession session)
INTERNAL:
Compares the value from the row and from the object (or cache).
|
boolean |
isNewerVersion(java.lang.Object firstLockFieldValue,
java.lang.Object secondWriteLockFieldValue)
INTERNAL:
Compares two values.
|
boolean |
isNewerVersion(java.lang.Object currentValue,
java.lang.Object domainObject,
java.lang.Object primaryKey,
AbstractSession session)
INTERNAL:
Compares the value with the value from the object (or cache).
|
void |
setUsesServerTime(boolean usesServerTime)
PUBLIC:
Set if policy uses server time.
|
void |
useLocalTime()
PUBLIC:
set this policy to get the time from the local machine.
|
void |
useServerTime()
PUBLIC:
set this policy to get the time from the server.
|
boolean |
usesLocalTime()
PUBLIC:
Return true if policy uses local time.
|
boolean |
usesServerTime()
PUBLIC:
Return true if policy uses server time.
|
addLockFieldsToUpdateRow, addLockValuesToTranslationRow, buildDeleteExpression, buildUpdateExpression, clone, getLockOnChangeMode, getVersionMapping, getWriteLockField, getWriteLockFieldName, initialize, initializeProperties, isCascaded, isStoredInCache, isStoredInObject, mergeIntoParentCache, mergeIntoParentCache, setDescriptor, setIsCascaded, setIsStoredInCache, setLockOnChangeMode, setupWriteFieldsForInsert, setWriteLockField, setWriteLockFieldName, shouldUpdateVersionOnMappingChange, shouldUpdateVersionOnOwnedMappingChange, storeInCache, storeInObject, supportsWriteLockValuesComparison, updateObjectWithWriteValue, updateRowAndObjectForUpdate, validateDelete, validateUpdate, writeLockValueIntoRowpublic static final int SERVER_TIME
public static final int LOCAL_TIME
public TimestampLockingPolicy()
public TimestampLockingPolicy(java.lang.String fieldName)
fieldName - the field where the write lock value will be stored.public TimestampLockingPolicy(DatabaseField field)
field - the field where the write lock value will be stored.public int compareWriteLockValues(java.lang.Object value1,
java.lang.Object value2)
compareWriteLockValues in interface OptimisticLockingPolicycompareWriteLockValues in class VersionLockingPolicypublic java.lang.Object getBaseValue()
getBaseValue in interface OptimisticLockingPolicygetBaseValue in class VersionLockingPolicypublic java.lang.Object getNewLockValue(ModifyQuery query)
getNewLockValue in class VersionLockingPolicypublic java.lang.Object getValueToPutInCache(AbstractRecord row, AbstractSession session)
getValueToPutInCache in interface OptimisticLockingPolicygetValueToPutInCache in class VersionLockingPolicypublic int getVersionDifference(java.lang.Object currentValue,
java.lang.Object domainObject,
java.lang.Object primaryKeys,
AbstractSession session)
getVersionDifference in interface OptimisticLockingPolicygetVersionDifference in class VersionLockingPolicycurrentValue - the new lock valuedomainObject - the object containing the version to be compared toprimaryKeys - a vector containing the primary keys of the domainObjectsession - the session to be used with the comparisonpublic java.lang.Object getWriteLockValue(java.lang.Object domainObject,
java.lang.Object primaryKey,
AbstractSession session)
getWriteLockValue in interface OptimisticLockingPolicygetWriteLockValue in class VersionLockingPolicypublic Expression getWriteLockUpdateExpression(ExpressionBuilder builder, AbstractSession session)
getWriteLockUpdateExpression in interface OptimisticLockingPolicygetWriteLockUpdateExpression in class VersionLockingPolicypublic boolean isNewerVersion(java.lang.Object currentValue,
java.lang.Object domainObject,
java.lang.Object primaryKey,
AbstractSession session)
isNewerVersion in interface OptimisticLockingPolicyisNewerVersion in class VersionLockingPolicypublic boolean isNewerVersion(AbstractRecord databaseRow, java.lang.Object domainObject, java.lang.Object primaryKey, AbstractSession session)
isNewerVersion in interface OptimisticLockingPolicyisNewerVersion in class VersionLockingPolicypublic boolean isNewerVersion(java.lang.Object firstLockFieldValue,
java.lang.Object secondWriteLockFieldValue)
isNewerVersion in class VersionLockingPolicypublic void setUsesServerTime(boolean usesServerTime)
public void useLocalTime()
public void useServerTime()
public boolean usesLocalTime()
public boolean usesServerTime()
EclipseLink 2.6.3, "build v20160428-59c81c5" API Reference