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);
}
}