public class TimestampLockingPolicy extends VersionLockingPolicy
Purpose: Used to allow a single version timestamp to be used for optimistic locking.
| Modifier and Type | Field and Description |
|---|---|
static int |
LOCAL_TIME |
protected int |
retrieveTimeFrom |
static int |
SERVER_TIME |
cachedExpression, descriptor, IN_CACHE, IN_OBJECT, isCascaded, lockMapping, lockOnChangeMode, lockValueStored, writeLockField| Constructor and Description |
|---|
TimestampLockingPolicy()
PUBLIC:
Create a new TimestampLockingPolicy.
|
TimestampLockingPolicy(org.eclipse.persistence.internal.helper.DatabaseField field)
INTERNAL:
Create a new TimestampLockingPolicy.
|
TimestampLockingPolicy(String fieldName)
PUBLIC:
Create a new TimestampLockingPolicy.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareWriteLockValues(Object value1,
Object value2)
INTERNAL:
This method compares two writeLockValues.
|
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.
|
protected Class |
getDefaultLockingFieldType()
INTERNAL:
Return the default timestamp locking filed java type, default is Timestamp.
|
protected Object |
getInitialWriteValue(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:
returns the initial locking value
|
Object |
getNewLockValue(ModifyQuery query)
INTERNAL:
Returns the new Timestamp value.
|
Object |
getValueToPutInCache(org.eclipse.persistence.internal.sessions.AbstractRecord row,
org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:
Return the value that should be stored in the identity map.
|
int |
getVersionDifference(Object currentValue,
Object domainObject,
Object primaryKeys,
org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:
Return the number of versions different between these objects.
|
Expression |
getWriteLockUpdateExpression(ExpressionBuilder builder,
org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:
Return an expression that updates the write lock
|
Object |
getWriteLockValue(Object domainObject,
Object primaryKey,
org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:
This method will return the optimistic lock value for the object.
|
protected Number |
incrementWriteLockValue(Number numberValue)
INTERNAL:
Timestamp versioning should not be able to do this.
|
boolean |
isNewerVersion(org.eclipse.persistence.internal.sessions.AbstractRecord databaseRow,
Object domainObject,
Object primaryKey,
org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:
Compares the value from the row and from the object (or cache).
|
boolean |
isNewerVersion(Object firstLockFieldValue,
Object secondWriteLockFieldValue)
INTERNAL:
Compares two values.
|
boolean |
isNewerVersion(Object currentValue,
Object domainObject,
Object primaryKey,
org.eclipse.persistence.internal.sessions.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, buildExpression, buildUpdateExpression, clone, getDescriptor, getLockOnChangeMode, getUnmappedFields, getVersionMapping, getWriteLockField, getWriteLockFieldName, initialize, initializeProperties, isCascaded, isStoredInCache, isStoredInObject, lockValueFromObject, mergeIntoParentCache, mergeIntoParentCache, setDescriptor, setIsCascaded, setIsStoredInCache, setLockOnChangeMode, setupWriteFieldsForInsert, setWriteLockField, setWriteLockFieldName, shouldUpdateVersionOnMappingChange, shouldUpdateVersionOnOwnedMappingChange, storeInCache, storeInObject, supportsWriteLockValuesComparison, updateObjectWithWriteValue, updateRowAndObjectForUpdate, updateWriteLockValueForWrite, validateDelete, validateUpdate, writeLockValueIntoRowprotected int retrieveTimeFrom
public static final int SERVER_TIME
public static final int LOCAL_TIME
public TimestampLockingPolicy()
public TimestampLockingPolicy(String fieldName)
fieldName - the field where the write lock value will be stored.public TimestampLockingPolicy(org.eclipse.persistence.internal.helper.DatabaseField field)
field - the field where the write lock value will be stored.public int compareWriteLockValues(Object value1, Object value2)
compareWriteLockValues in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicycompareWriteLockValues in class VersionLockingPolicyprotected Class getDefaultLockingFieldType()
getDefaultLockingFieldType in class VersionLockingPolicypublic Object getBaseValue()
getBaseValue in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicygetBaseValue in class VersionLockingPolicyprotected Object getInitialWriteValue(org.eclipse.persistence.internal.sessions.AbstractSession session)
getInitialWriteValue in class VersionLockingPolicypublic Object getNewLockValue(ModifyQuery query)
getNewLockValue in class VersionLockingPolicypublic Object getValueToPutInCache(org.eclipse.persistence.internal.sessions.AbstractRecord row, org.eclipse.persistence.internal.sessions.AbstractSession session)
getValueToPutInCache in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicygetValueToPutInCache in class VersionLockingPolicypublic int getVersionDifference(Object currentValue, Object domainObject, Object primaryKeys, org.eclipse.persistence.internal.sessions.AbstractSession session)
getVersionDifference in interface org.eclipse.persistence.internal.descriptors.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 Object getWriteLockValue(Object domainObject, Object primaryKey, org.eclipse.persistence.internal.sessions.AbstractSession session)
getWriteLockValue in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicygetWriteLockValue in class VersionLockingPolicypublic Expression getWriteLockUpdateExpression(ExpressionBuilder builder, org.eclipse.persistence.internal.sessions.AbstractSession session)
getWriteLockUpdateExpression in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicygetWriteLockUpdateExpression in class VersionLockingPolicyprotected Number incrementWriteLockValue(Number numberValue)
incrementWriteLockValue in class VersionLockingPolicypublic boolean isNewerVersion(Object currentValue, Object domainObject, Object primaryKey, org.eclipse.persistence.internal.sessions.AbstractSession session)
isNewerVersion in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicyisNewerVersion in class VersionLockingPolicypublic boolean isNewerVersion(org.eclipse.persistence.internal.sessions.AbstractRecord databaseRow,
Object domainObject,
Object primaryKey,
org.eclipse.persistence.internal.sessions.AbstractSession session)
isNewerVersion in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicyisNewerVersion in class VersionLockingPolicypublic boolean isNewerVersion(Object firstLockFieldValue, Object secondWriteLockFieldValue)
isNewerVersion in class VersionLockingPolicypublic void setUsesServerTime(boolean usesServerTime)
public void useLocalTime()
public void useServerTime()
public boolean usesLocalTime()
public boolean usesServerTime()
Copyright © 2007–2021 Eclipse.org - EclipseLink Project. All rights reserved.