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