/** * PUBLIC: * Set the locking policy to use timestamp version locking. * This updates the timestamp field on all updates, first comparing that the field has not changed to detect locking conflicts. * Note: many database have limited precision of timestamps which can be an issue is highly concurrent systems. * * The parameter 'shouldStoreInCache' configures the version lock value to be stored in the cache or in the object. * Note: if using a stateless model where the object can be passed to a client and then later updated in a different transaction context, * then the version lock value should not be stored in the cache, but in the object to ensure it is the correct value for that object. * @see VersionLockingPolicy */ public void useTimestampLocking(String writeLockFieldName, boolean shouldStoreInCache) { TimestampLockingPolicy policy = new TimestampLockingPolicy(writeLockFieldName); if (shouldStoreInCache) { policy.storeInCache(); } else { policy.storeInObject(); } setOptimisticLockingPolicy(policy); }
/** * PUBLIC: * Set the locking policy to use timestamp version locking. * This updates the timestamp field on all updates, first comparing that the field has not changed to detect locking conflicts. * Note: many database have limited precision of timestamps which can be an issue is highly concurrent systems. * * The parameter 'shouldStoreInCache' configures the version lock value to be stored in the cache or in the object. * Note: if using a stateless model where the object can be passed to a client and then later updated in a different transaction context, * then the version lock value should not be stored in the cache, but in the object to ensure it is the correct value for that object. * @see VersionLockingPolicy */ public void useTimestampLocking(String writeLockFieldName, boolean shouldStoreInCache) { TimestampLockingPolicy policy = new TimestampLockingPolicy(writeLockFieldName); if (shouldStoreInCache) { policy.storeInCache(); } else { policy.storeInObject(); } setOptimisticLockingPolicy(policy); }
/** * PUBLIC: * Set the locking policy to use timestamp version locking. * This updates the timestamp field on all updates, first comparing that the field has not changed to detect locking conflicts. * Note: many database have limited precision of timestamps which can be an issue is highly concurrent systems. * * The parameter 'shouldStoreInCache' configures the version lock value to be stored in the cache or in the object. * Note: if using a stateless model where the object can be passed to a client and then later updated in a different transaction context, * then the version lock value should not be stored in the cache, but in the object to ensure it is the correct value for that object. * @see VersionLockingPolicy */ public void useTimestampLocking(String writeLockFieldName, boolean shouldStoreInCache) { TimestampLockingPolicy policy = new TimestampLockingPolicy(writeLockFieldName); if (shouldStoreInCache) { policy.storeInCache(); } else { policy.storeInObject(); } setOptimisticLockingPolicy(policy); }