public Object checkIfAlreadyRegistered(Object object, ClassDescriptor descriptor) {
        // Don't register read-only classes
        if (isClassReadOnly(object.getClass(), descriptor)) {
            return null;
        }
        // Check if the working copy is again being registered in which case we return the same working copy
        Object registeredObject = getCloneMapping().get(object);
        if (registeredObject != null) {
            return object;
        }
        // Check if object exists in my new objects if it is in the new objects cache then it means domain object is being 
        // re-registered and we should return the same working clone. This check holds only for the new registered objects 
        // PERF: Avoid initialization of new objects if none.
        if (hasNewObjects()) {
            registeredObject = getNewObjectsOriginalToClone().get(object);
            if (registeredObject != null) {
                return registeredObject;
            }
        }
        if (this.isNestedUnitOfWork) {
            // bug # 3228185
            //may be a new object from a parent Unit Of Work, let's check our new object in parent list to see
            //if it has already been registered locally
            if (hasNewObjectsInParentOriginalToClone()) {
                registeredObject = getNewObjectsInParentOriginalToClone().get(object);
            }
            if (registeredObject != null) {
                return registeredObject;
            }
        }
        return null;
    }
public Object checkIfAlreadyRegistered(Object object, ClassDescriptor descriptor) {
       
        if (isClassReadOnly(object.getClass(), descriptor)) {
            return null;
        }
       
        Object registeredObject = getCloneMapping().get(object);
        if (registeredObject != null) {
            return object;
        }
       
       
       
        if (hasNewObjects()) {
            registeredObject = getNewObjectsOriginalToClone().get(object);
            if (registeredObject != null) {
                return registeredObject;
            }
        }
        if (this.isNestedUnitOfWork) {
           
           
           
            if (hasNewObjectsInParentOriginalToClone()) {
                registeredObject = getNewObjectsInParentOriginalToClone().get(object);
            }
            if (registeredObject != null) {
                return registeredObject;
            }
        }
        return null;
    }
public object checkifalreadyregistered(object object, classdescriptor descriptor) { if (isclassreadonly(object.getclass(), descriptor)) { return null; } object registeredobject = getclonemapping().get(object); if (registeredobject != null) { return object; } if (hasnewobjects()) { registeredobject = getnewobjectsoriginaltoclone().get(object); if (registeredobject != null) { return registeredobject; } } if (this.isnestedunitofwork) { if (hasnewobjectsinparentoriginaltoclone()) { registeredobject = getnewobjectsinparentoriginaltoclone().get(object); } if (registeredobject != null) { return registeredobject; } } return null; }