/** * INTERNAL: * Compare the attributes belonging to this mapping for the objects. */ @Override public boolean compareObjects(Object firstObject, Object secondObject, AbstractSession session) { Object firstObjectCollection = getRealCollectionAttributeValueFromObject(firstObject, session); Object secondObjectCollection = getRealCollectionAttributeValueFromObject(secondObject, session); return super.compareObjects(firstObjectCollection, secondObjectCollection, session); }
/** * INTERNAL: * Compare the attributes belonging to this mapping for the objects. */ @Override public boolean compareObjects(Object firstObject, Object secondObject, AbstractSession session) { Object firstObjectCollection = getRealCollectionAttributeValueFromObject(firstObject, session); Object secondObjectCollection = getRealCollectionAttributeValueFromObject(secondObject, session); return super.compareObjects(firstObjectCollection, secondObjectCollection, session); }
/** * INTERNAL: * Compare the attributes belonging to this mapping for the objects. */ public boolean compareObjects(Object firstObject, Object secondObject, AbstractSession session) { Object firstObjectCollection = getRealCollectionAttributeValueFromObject(firstObject, session); Object secondObjectCollection = getRealCollectionAttributeValueFromObject(secondObject, session); return super.compareObjects(firstObjectCollection, secondObjectCollection, session); }
/** * INTERNAL: * Cascade perform removal of orphaned private owned objects from the UnitOfWorkChangeSet */ @Override public void cascadePerformRemovePrivateOwnedObjectFromChangeSetIfRequired(Object object, UnitOfWorkImpl uow, Map visitedObjects) { // if the object is not instantiated, do not instantiate or cascade Object attributeValue = getAttributeValueFromObject(object); if (attributeValue != null && this.indirectionPolicy.objectIsInstantiated(attributeValue)) { Object realObjectCollection = getRealCollectionAttributeValueFromObject(object, uow); ContainerPolicy cp = this.containerPolicy; for (Object cloneIter = cp.iteratorFor(realObjectCollection); cp.hasNext(cloneIter);) { Object nextObject = cp.next(cloneIter, uow); if (nextObject != null && !visitedObjects.containsKey(nextObject)) { visitedObjects.put(nextObject, nextObject); // remove the object from the UnitOfWork ChangeSet uow.performRemovePrivateOwnedObjectFromChangeSet(nextObject, visitedObjects); } } } }
/** * INTERNAL: * Cascade perform removal of orphaned private owned objects from the UnitOfWorkChangeSet */ @Override public void cascadePerformRemovePrivateOwnedObjectFromChangeSetIfRequired(Object object, UnitOfWorkImpl uow, Map visitedObjects) { // if the object is not instantiated, do not instantiate or cascade Object attributeValue = getAttributeValueFromObject(object); if (attributeValue != null && this.indirectionPolicy.objectIsInstantiated(attributeValue)) { Object realObjectCollection = getRealCollectionAttributeValueFromObject(object, uow); ContainerPolicy cp = this.containerPolicy; for (Object cloneIter = cp.iteratorFor(realObjectCollection); cp.hasNext(cloneIter);) { Object nextObject = cp.next(cloneIter, uow); if (nextObject != null && !visitedObjects.containsKey(nextObject)) { visitedObjects.put(nextObject, nextObject); // remove the object from the UnitOfWork ChangeSet uow.performRemovePrivateOwnedObjectFromChangeSet(nextObject, visitedObjects); } } } }
/** * INTERNAL: * Cascade perform removal of orphaned private owned objects from the UnitOfWorkChangeSet */ public void cascadePerformRemovePrivateOwnedObjectFromChangeSetIfRequired(Object object, UnitOfWorkImpl uow, Map visitedObjects) { // if the object is not instantiated, do not instantiate or cascade Object attributeValue = getAttributeValueFromObject(object); if (attributeValue != null && this.indirectionPolicy.objectIsInstantiated(attributeValue)) { Object realObjectCollection = getRealCollectionAttributeValueFromObject(object, uow); ContainerPolicy cp = this.containerPolicy; for (Object cloneIter = cp.iteratorFor(realObjectCollection); cp.hasNext(cloneIter);) { Object nextObject = cp.next(cloneIter, uow); if (nextObject != null && !visitedObjects.containsKey(nextObject)) { visitedObjects.put(nextObject, nextObject); // remove the object from the UnitOfWork ChangeSet uow.performRemovePrivateOwnedObjectFromChangeSet(nextObject, visitedObjects); } } } }
/** * INTERNAL: * Cascade perform delete through mappings that require the cascade */ public void cascadePerformRemoveIfRequired(Object object, UnitOfWorkImpl uow, Map visitedObjects) { if (!isCascadeRemove()) { return; } Object cloneAttribute = getAttributeValueFromObject(object); if (cloneAttribute == null) { return; } ContainerPolicy cp = this.containerPolicy; Object cloneObjectCollection = null; cloneObjectCollection = getRealCollectionAttributeValueFromObject(object, uow); Object cloneIter = cp.iteratorFor(cloneObjectCollection); while (cp.hasNext(cloneIter)) { Object wrappedObject = cp.nextEntry(cloneIter, uow); Object nextObject = cp.unwrapIteratorResult(wrappedObject); if ((nextObject != null) && (!visitedObjects.containsKey(nextObject))) { visitedObjects.put(nextObject, nextObject); uow.performRemove(nextObject, visitedObjects); cp.cascadePerformRemoveIfRequired(wrappedObject, uow, visitedObjects); } } }
cloneObjectCollection = getRealCollectionAttributeValueFromObject(object, uow); Object cloneIter = cp.iteratorFor(cloneObjectCollection); while (cp.hasNext(cloneIter)) {
Object cloneObjectCollection = null; if (cloneAttribute != null) { cloneObjectCollection = getRealCollectionAttributeValueFromObject(clone, session); } else { cloneObjectCollection = cp.containerInstance(1);
/** * INTERNAL: * All the privately owned parts are read */ protected Object readPrivateOwnedForObject(ObjectLevelModifyQuery modifyQuery) throws DatabaseException { if (modifyQuery.getSession().isUnitOfWork()) { return getRealCollectionAttributeValueFromObject(modifyQuery.getBackupClone(), modifyQuery.getSession()); } else { // cr 3819 prepareTranslationRow(modifyQuery.getTranslationRow(), modifyQuery.getObject(), modifyQuery.getDescriptor(), modifyQuery.getSession()); return modifyQuery.getSession().executeQuery(getSelectionQuery(), modifyQuery.getTranslationRow()); } }
/** * INTERNAL: * All the privately owned parts are read */ protected Object readPrivateOwnedForObject(ObjectLevelModifyQuery modifyQuery) throws DatabaseException { if (modifyQuery.getSession().isUnitOfWork()) { return getRealCollectionAttributeValueFromObject(modifyQuery.getBackupClone(), modifyQuery.getSession()); } else { // cr 3819 prepareTranslationRow(modifyQuery.getTranslationRow(), modifyQuery.getObject(), modifyQuery.getSession()); return modifyQuery.getSession().executeQuery(getSelectionQuery(), modifyQuery.getTranslationRow()); } }
/** * INTERNAL: * All the privately owned parts are read */ protected Object readPrivateOwnedForObject(ObjectLevelModifyQuery modifyQuery) throws DatabaseException { if (modifyQuery.getSession().isUnitOfWork()) { return getRealCollectionAttributeValueFromObject(modifyQuery.getBackupClone(), modifyQuery.getSession()); } else { // cr 3819 prepareTranslationRow(modifyQuery.getTranslationRow(), modifyQuery.getObject(), modifyQuery.getDescriptor(), modifyQuery.getSession()); return modifyQuery.getSession().executeQuery(getSelectionQuery(), modifyQuery.getTranslationRow()); } }
/** * INTERNAL: * Copy of the attribute of the object. * This is NOT used for unit of work but for templatizing an object. */ public void buildCopy(Object copy, Object original, ObjectCopyingPolicy policy) { Object attributeValue = getRealCollectionAttributeValueFromObject(original, policy.getSession()); Object valuesIterator = this.containerPolicy.iteratorFor(attributeValue); attributeValue = this.containerPolicy.containerInstance(this.containerPolicy.sizeFor(attributeValue)); while (this.containerPolicy.hasNext(valuesIterator)) { Object originalValue = this.containerPolicy.next(valuesIterator, policy.getSession()); Object copyValue = originalValue; if (policy.shouldCascadeAllParts() || (policy.shouldCascadePrivateParts() && isPrivateOwned())) { copyValue = policy.getSession().copyObject(originalValue, policy); } else { // Check for backrefs to copies. copyValue = policy.getCopies().get(originalValue); if (copyValue == null) { copyValue = originalValue; } } this.containerPolicy.addInto(copyValue, attributeValue, policy.getSession()); } setRealAttributeValueInObject(copy, attributeValue); }
cloneObjectCollection = getRealCollectionAttributeValueFromObject(object, uow); Object cloneIter = cp.iteratorFor(cloneObjectCollection);
/** * INTERNAL: * Checks if object is deleted from the database or not. */ public boolean verifyDelete(Object object, AbstractSession session) throws DatabaseException { // Row is built for translation if (isReadOnly()) { return true; } if (isPrivateOwned()) { Object objects = getRealCollectionAttributeValueFromObject(object, session); ContainerPolicy containerPolicy = this.containerPolicy; for (Object iter = containerPolicy.iteratorFor(objects); containerPolicy.hasNext(iter);) { if (!session.verifyDelete(containerPolicy.next(iter, session))) { return false; } } } AbstractRecord row = getDescriptor().getObjectBuilder().buildRowForTranslation(object, session); //cr 3819 added the line below to fix the translationtable to ensure that it // contains the required values prepareTranslationRow(row, object, session); Object value = session.executeQuery(getSelectionQuery(), row); return this.containerPolicy.isEmpty(value); }
/** * INTERNAL: * Cascade registerNew for Create through mappings that require the cascade */ public void cascadeRegisterNewIfRequired(Object object, UnitOfWorkImpl uow, Map visitedObjects) { if (!isCascadePersist()) { return; } Object cloneAttribute = getAttributeValueFromObject(object); if ((cloneAttribute == null) || (!this.indirectionPolicy.objectIsInstantiated(cloneAttribute))) { return; } ContainerPolicy cp = this.containerPolicy; Object cloneObjectCollection = null; cloneObjectCollection = getRealCollectionAttributeValueFromObject(object, uow); Object cloneIter = cp.iteratorFor(cloneObjectCollection); // add private owned objects to uow list if mapping is a candidate and uow should discover new objects and the source object is new. boolean shouldAddPrivateOwnedObject = isCandidateForPrivateOwnedRemoval() && uow.shouldDiscoverNewObjects() && uow.isObjectNew(object); while (cp.hasNext(cloneIter)) { Object wrappedObject = cp.nextEntry(cloneIter, uow); Object nextObject = cp.unwrapIteratorResult(wrappedObject); if (shouldAddPrivateOwnedObject && nextObject != null) { uow.addPrivateOwnedObject(this, nextObject); } uow.registerNewObjectForPersist(nextObject, visitedObjects); cp.cascadeRegisterNewIfRequired(wrappedObject, uow, visitedObjects); } }
/** * INTERNAL: * Checks if object is deleted from the database or not. */ @Override public boolean verifyDelete(Object object, AbstractSession session) throws DatabaseException { // Row is built for translation if (isReadOnly()) { return true; } if (isPrivateOwned() || isCascadeRemove()) { Object objects = getRealCollectionAttributeValueFromObject(object, session); ContainerPolicy containerPolicy = this.containerPolicy; for (Object iter = containerPolicy.iteratorFor(objects); containerPolicy.hasNext(iter);) { if (!session.verifyDelete(containerPolicy.next(iter, session))) { return false; } } } AbstractRecord row = getDescriptor().getObjectBuilder().buildRowForTranslation(object, session); //cr 3819 added the line below to fix the translationtable to ensure that it // contains the required values prepareTranslationRow(row, object, getDescriptor(), session); Object value = session.executeQuery(getSelectionQuery(), row); return this.containerPolicy.isEmpty(value); }
Object attributeValue = getRealCollectionAttributeValueFromObject(original, group.getSession()); Object valuesIterator = this.containerPolicy.iteratorFor(attributeValue); attributeValue = this.containerPolicy.containerInstance(this.containerPolicy.sizeFor(attributeValue));
/** * INTERNAL: * Checks if object is deleted from the database or not. */ @Override public boolean verifyDelete(Object object, AbstractSession session) throws DatabaseException { // Row is built for translation if (isReadOnly()) { return true; } if (isPrivateOwned() || isCascadeRemove()) { Object objects = getRealCollectionAttributeValueFromObject(object, session); ContainerPolicy containerPolicy = this.containerPolicy; for (Object iter = containerPolicy.iteratorFor(objects); containerPolicy.hasNext(iter);) { if (!session.verifyDelete(containerPolicy.next(iter, session))) { return false; } } } AbstractRecord row = getDescriptor().getObjectBuilder().buildRowForTranslation(object, session); //cr 3819 added the line below to fix the translationtable to ensure that it // contains the required values prepareTranslationRow(row, object, getDescriptor(), session); Object value = session.executeQuery(getSelectionQuery(), row); return this.containerPolicy.isEmpty(value); }
Object attributeValue = getRealCollectionAttributeValueFromObject(original, group.getSession()); Object valuesIterator = this.containerPolicy.iteratorFor(attributeValue); attributeValue = this.containerPolicy.containerInstance(this.containerPolicy.sizeFor(attributeValue));