/** * Check if the new object's version has been set, if so, then it was an existing object that was deleted. * Raise an error instead of reincarnating the object. */ public void checkNewObjectLockVersion(Object clone, Object primaryKey, ClassDescriptor descriptor, UnitOfWorkImpl unitOfWork) { //bug272704: throw an exception if this object is new yet has a version set to avoid merging in deleted objects if (descriptor.usesVersionLocking()){ VersionLockingPolicy policy = (VersionLockingPolicy)descriptor.getOptimisticLockingPolicy(); Object baseValue = policy.getBaseValue(); Object objectLockValue = policy.getWriteLockValue(clone, primaryKey, unitOfWork); if (policy.isNewerVersion(objectLockValue, baseValue)) { throw OptimisticLockException.objectChangedSinceLastMerge(clone); } } }
/** * Check if the new object's version has been set, if so, then it was an existing object that was deleted. * Raise an error instead of reincarnating the object. */ public void checkNewObjectLockVersion(Object clone, Object primaryKey, ClassDescriptor descriptor, UnitOfWorkImpl unitOfWork) { //bug272704: throw an exception if this object is new yet has a version set to avoid merging in deleted objects if (descriptor.usesVersionLocking()){ VersionLockingPolicy policy = (VersionLockingPolicy)descriptor.getOptimisticLockingPolicy(); Object baseValue = policy.getBaseValue(); Object objectLockValue = policy.getWriteLockValue(clone, primaryKey, unitOfWork); if (policy.isNewerVersion(objectLockValue, baseValue)) { throw OptimisticLockException.objectChangedSinceLastMerge(clone); } } }
/** * INTERNAL: * This method updates the modify row with the old lock value. */ public void writeLockValueIntoRow(ObjectLevelModifyQuery query, Object domainObject) { Object lockValue = getWriteLockValue(domainObject, query.getPrimaryKey(), query.getSession()); query.getModifyRow().put(this.writeLockField, lockValue); if (isStoredInCache()) { query.getSession().getIdentityMapAccessor().updateWriteLockValue(query.getPrimaryKey(), domainObject.getClass(), lockValue); } }
/** * INTERNAL: * This method updates the modify row with the old lock value. */ public void writeLockValueIntoRow(ObjectLevelModifyQuery query, Object domainObject) { Object lockValue = getWriteLockValue(domainObject, query.getPrimaryKey(), query.getSession()); query.getModifyRow().put(this.writeLockField, lockValue); if (isStoredInCache()) { query.getSession().getIdentityMapAccessor().updateWriteLockValue(query.getPrimaryKey(), domainObject.getClass(), lockValue); } }
/** * INTERNAL: * This method updates the modify row with the old lock value. */ public void writeLockValueIntoRow(ObjectLevelModifyQuery query, Object domainObject) { Object lockValue = getWriteLockValue(domainObject, query.getPrimaryKey(), query.getSession()); query.getModifyRow().put(this.writeLockField, lockValue); if (isStoredInCache()) { query.getSession().getIdentityMapAccessor().updateWriteLockValue(query.getPrimaryKey(), domainObject.getClass(), lockValue); } }
VersionLockingPolicy policy = (VersionLockingPolicy)descriptor.getOptimisticLockingPolicy(); Object baseValue = policy.getBaseValue(); Object objectLockValue = policy.getWriteLockValue(clone, primaryKey, unitOfWork); if ( policy.isNewerVersion(objectLockValue, baseValue) ) { throw OptimisticLockException.objectChangedSinceLastMerge(clone); VersionLockingPolicy policy = (VersionLockingPolicy)descriptor.getOptimisticLockingPolicy(); Object baseValue = policy.getBaseValue(); Object objectLockValue = policy.getWriteLockValue(clone, primaryKey, unitOfWork); if ( policy.isNewerVersion(objectLockValue, baseValue) ) { throw OptimisticLockException.objectChangedSinceLastMerge(clone); VersionLockingPolicy policy = (VersionLockingPolicy)descriptor.getOptimisticLockingPolicy(); Object baseValue = policy.getBaseValue(); Object objectLockValue = policy.getWriteLockValue(clone, primaryKey, unitOfWork); if ( policy.isNewerVersion(objectLockValue, baseValue) ) { throw OptimisticLockException.objectChangedSinceLastMerge(clone);
/** * INTERNAL: * Check the row count for lock failure. */ public void validateDelete(int rowCount, Object object, DeleteObjectQuery query) { if (rowCount <= 0) { // Mark the object as invalid in the session cache, only if version is the same as in query. Object primaryKey = query.getPrimaryKey(); AbstractSession session = query.getSession().getParentIdentityMapSession(query, true, true); CacheKey cacheKey = session.getIdentityMapAccessorInstance().getCacheKeyForObject(primaryKey, query.getReferenceClass(), query.getDescriptor(), false); if ((cacheKey != null) && (cacheKey.getObject() != null) && (query.getObjectChangeSet() != null)) { Object queryVersion = query.getObjectChangeSet().getInitialWriteLockValue(); Object cacheVersion = getWriteLockValue(cacheKey.getObject(), primaryKey, session); if (compareWriteLockValues(queryVersion, cacheVersion) != 0) { cacheKey.setInvalidationState(CacheKey.CACHE_KEY_INVALID); } } throw OptimisticLockException.objectChangedSinceLastReadWhenDeleting(object, query); } }
/** * INTERNAL: * Check the row count for lock failure. */ public void validateUpdate(int rowCount, Object object, WriteObjectQuery query) { if (rowCount <= 0) { // Mark the object as invalid in the session cache, only if version is the same as in query. Object primaryKey = query.getPrimaryKey(); AbstractSession session = query.getSession().getParentIdentityMapSession(query, true, true); CacheKey cacheKey = session.getIdentityMapAccessorInstance().getCacheKeyForObject(primaryKey, query.getReferenceClass(), query.getDescriptor(), false); if ((cacheKey != null) && (cacheKey.getObject() != null) && (query.getObjectChangeSet() != null)) { Object queryVersion = query.getObjectChangeSet().getInitialWriteLockValue(); Object cacheVersion = getWriteLockValue(cacheKey.getObject(), primaryKey, session); if (compareWriteLockValues(queryVersion, cacheVersion) >= 0) { cacheKey.setInvalidationState(CacheKey.CACHE_KEY_INVALID); } } throw OptimisticLockException.objectChangedSinceLastReadWhenUpdating(object, query); } } }
/** * INTERNAL: * Check the row count for lock failure. */ public void validateUpdate(int rowCount, Object object, WriteObjectQuery query) { if (rowCount <= 0) { // Mark the object as invalid in the session cache, only if version is the same as in query. Vector primaryKey = query.getPrimaryKey(); AbstractSession session = query.getSession().getParentIdentityMapSession(query, true, true); CacheKey cacheKey = session.getIdentityMapAccessorInstance().getCacheKeyForObject(primaryKey, query.getReferenceClass(), query.getDescriptor()); if ((cacheKey != null) && (cacheKey.getObject() != null) && (query.getObjectChangeSet() != null)) { Object queryVersion = query.getObjectChangeSet().getInitialWriteLockValue(); Object cacheVersion = getWriteLockValue(cacheKey.getObject(), primaryKey, session); if (compareWriteLockValues(queryVersion, cacheVersion) >= 0) { cacheKey.setInvalidationState(CacheKey.CACHE_KEY_INVALID); } } throw OptimisticLockException.objectChangedSinceLastReadWhenUpdating(object, query); } } }
/** * INTERNAL: * Check the row count for lock failure. */ public void validateDelete(int rowCount, Object object, DeleteObjectQuery query) { if (rowCount <= 0) { // Mark the object as invalid in the session cache, only if version is the same as in query. Object primaryKey = query.getPrimaryKey(); AbstractSession session = query.getSession().getParentIdentityMapSession(query, true, true); CacheKey cacheKey = session.getIdentityMapAccessorInstance().getCacheKeyForObject(primaryKey, query.getReferenceClass(), query.getDescriptor(), false); if ((cacheKey != null) && (cacheKey.getObject() != null) && (query.getObjectChangeSet() != null)) { Object queryVersion = query.getObjectChangeSet().getInitialWriteLockValue(); Object cacheVersion = getWriteLockValue(cacheKey.getObject(), primaryKey, session); if (compareWriteLockValues(queryVersion, cacheVersion) != 0) { cacheKey.setInvalidationState(CacheKey.CACHE_KEY_INVALID); } } throw OptimisticLockException.objectChangedSinceLastReadWhenDeleting(object, query); } }
/** * INTERNAL: * Check the row count for lock failure. */ public void validateDelete(int rowCount, Object object, DeleteObjectQuery query) { if (rowCount <= 0) { // Mark the object as invalid in the session cache, only if version is the same as in query. Vector primaryKey = query.getPrimaryKey(); AbstractSession session = query.getSession().getParentIdentityMapSession(query, true, true); CacheKey cacheKey = session.getIdentityMapAccessorInstance().getCacheKeyForObject(primaryKey, query.getReferenceClass(), query.getDescriptor()); if ((cacheKey != null) && (cacheKey.getObject() != null) && (query.getObjectChangeSet() != null)) { Object queryVersion = query.getObjectChangeSet().getInitialWriteLockValue(); Object cacheVersion = getWriteLockValue(cacheKey.getObject(), primaryKey, session); if (compareWriteLockValues(queryVersion, cacheVersion) != 0) { cacheKey.setInvalidationState(CacheKey.CACHE_KEY_INVALID); } } throw OptimisticLockException.objectChangedSinceLastReadWhenDeleting(object, query); } }
/** * INTERNAL: * Check the row count for lock failure. */ public void validateUpdate(int rowCount, Object object, WriteObjectQuery query) { if (rowCount <= 0) { // Mark the object as invalid in the session cache, only if version is the same as in query. Object primaryKey = query.getPrimaryKey(); AbstractSession session = query.getSession().getParentIdentityMapSession(query, true, true); CacheKey cacheKey = session.getIdentityMapAccessorInstance().getCacheKeyForObject(primaryKey, query.getReferenceClass(), query.getDescriptor(), false); if ((cacheKey != null) && (cacheKey.getObject() != null) && (query.getObjectChangeSet() != null)) { Object queryVersion = query.getObjectChangeSet().getInitialWriteLockValue(); Object cacheVersion = getWriteLockValue(cacheKey.getObject(), primaryKey, session); if (compareWriteLockValues(queryVersion, cacheVersion) >= 0) { cacheKey.setInvalidationState(CacheKey.CACHE_KEY_INVALID); } } throw OptimisticLockException.objectChangedSinceLastReadWhenUpdating(object, query); } } }