/** * INTERNAL: * Returns the real attribute value from the reference object's attribute value. * If the attribute is using indirection the value of the value-holder is returned. * If the value holder is not instantiated then it is instantiated. */ @Override public Object getRealAttributeValueFromAttribute(Object attributeValue, Object object, AbstractSession session) { return this.indirectionPolicy.getRealAttributeValueFromObject(object, attributeValue); }
/** * INTERNAL: * Returns the real attribute value from the reference object's attribute value. * If the attribute is using indirection the value of the value-holder is returned. * If the value holder is not instantiated then it is instantiated. */ @Override public Object getRealAttributeValueFromAttribute(Object attributeValue, Object object, AbstractSession session) { return this.indirectionPolicy.getRealAttributeValueFromObject(object, attributeValue); }
/** * INTERNAL: * Trigger the instantiation of the value. */ public void instantiateObject(Object object, Object attribute) { getRealAttributeValueFromObject(object, attribute); }
/** * INTERNAL: * Returns the attribute value from the reference object. * If the attribute is using indirection the value of the value-holder is returned. * If the value holder is not instantiated then it is instantiated. */ @Override public Object getRealAttributeValueFromAttribute(Object attributeValue, Object object, AbstractSession session) { return this.indirectionPolicy.getRealAttributeValueFromObject(object, attributeValue); }
/** * INTERNAL: * Returns the attribute value from the reference object. * If the attribute is using indirection the value of the value-holder is returned. * If the value holder is not instantiated then it is instantiated. */ public Object getRealAttributeValueFromAttribute(Object attributeValue, Object object, AbstractSession session) { return this.indirectionPolicy.getRealAttributeValueFromObject(object, attributeValue); }
/** * INTERNAL: * Trigger the instantiation of the value. */ public void instantiateObject(Object object, Object attribute) { getRealAttributeValueFromObject(object, attribute); }
/** * INTERNAL: * Returns the attribute value from the reference object. * If the attribute is using indirection the value of the value-holder is returned. * If the value holder is not instantiated then it is instantiated. */ @Override public Object getRealAttributeValueFromAttribute(Object attributeValue, Object object, AbstractSession session) { return this.indirectionPolicy.getRealAttributeValueFromObject(object, attributeValue); }
/** * INTERNAL: * Trigger the instantiation of the value. */ public void instantiateObject(Object object, Object attribute) { getRealAttributeValueFromObject(object, attribute); }
/** * INTERNAL: * Returns the real attribute value from the reference object's attribute value. * If the attribute is using indirection the value of the value-holder is returned. * If the value holder is not instantiated then it is instantiated. */ public Object getRealAttributeValueFromAttribute(Object attributeValue, Object object, AbstractSession session) { return this.indirectionPolicy.getRealAttributeValueFromObject(object, attributeValue); }
/** * INTERNAL: * This method will access the target relationship and create a list of information to rebuild the relationship. * This method is used in combination with the CachedValueHolder to store references to PK's to be loaded * from a cache instead of a query. */ @Override public Object[] buildReferencesPKList(Object entity, Object attribute, AbstractSession session){ Object container = indirectionPolicy.getRealAttributeValueFromObject(entity, attribute); return containerPolicy.buildReferencesPKList(container, session); }
/** * INTERNAL: * This method will access the target relationship and create a list of information to rebuild the relationship. * This method is used in combination with the CachedValueHolder to store references to PK's to be loaded * from a cache instead of a query. */ @Override public Object[] buildReferencesPKList(Object entity, Object attribute, AbstractSession session){ Object container = indirectionPolicy.getRealAttributeValueFromObject(entity, attribute); return containerPolicy.buildReferencesPKList(container, session); }
/** * INTERNAL: * Cascade remove through mappings that require the cascade. * @param object is either the source object, or attribute value if getAttributeValueFromObject is true. */ public void cascadePerformRemoveIfRequired(Object object, UnitOfWorkImpl uow, Map visitedObjects, boolean getAttributeValueFromObject) { if (!isCascadeRemove()) { return; } Object attributeValue = null; if (getAttributeValueFromObject) { attributeValue = getAttributeValueFromObject(object); } else { attributeValue = object; } if (attributeValue != null) { if (getAttributeValueFromObject) { attributeValue = this.indirectionPolicy.getRealAttributeValueFromObject(object, attributeValue); } if (attributeValue != null && (! visitedObjects.containsKey(attributeValue)) ){ visitedObjects.put(attributeValue, attributeValue); uow.performRemove(attributeValue, visitedObjects); } } }
/** * INTERNAL: This method will access the target relationship and create a * list of PKs of the target entities. This method is used in combination * with the CachedValueHolder to store references to PK's to be loaded from * a cache instead of a query. * @see org.eclipse.persistence.internal.queries.ContainerPolicy#buildReferencesPKList * @see org.eclipse.persistence.internal.queries.MappedKeyMapContainerPolicy */ @Override public Object[] buildReferencesPKList(Object entity, Object attribute, AbstractSession session) { ClassDescriptor referenceDescriptor = getReferenceDescriptor(); Object target = this.indirectionPolicy.getRealAttributeValueFromObject(entity, attribute); if (target != null){ Object[] result = new Object[1]; result[0] = referenceDescriptor.getObjectBuilder().extractPrimaryKeyFromObject(target, session); return result; } return new Object[]{}; }
/** * INTERNAL: This method will access the target relationship and create a * list of PKs of the target entities. This method is used in combination * with the CachedValueHolder to store references to PK's to be loaded from * a cache instead of a query. * @see org.eclipse.persistence.internal.queries.ContainerPolicy#buildReferencesPKList * @see org.eclipse.persistence.internal.queries.MappedKeyMapContainerPolicy */ @Override public Object[] buildReferencesPKList(Object entity, Object attribute, AbstractSession session) { ClassDescriptor referenceDescriptor = getReferenceDescriptor(); Object target = this.indirectionPolicy.getRealAttributeValueFromObject(entity, attribute); if (target != null){ Object[] result = new Object[1]; result[0] = referenceDescriptor.getObjectBuilder().extractPrimaryKeyFromObject(target, session); return result; } return new Object[]{}; }
/** * INTERNAL: * This method will access the target relationship and create a list of PKs of the target entities. * This method is used in combination with the CachedValueHolder to store references to PK's to be loaded * from a cache instead of a query. */ public Object[] buildReferencesPKList(Object entity, Object attribute, AbstractSession session){ ClassDescriptor referenceDescriptor = getReferenceDescriptor(); Object collection = this.indirectionPolicy.getRealAttributeValueFromObject(entity, attribute); Object[] result = new Object[this.containerPolicy.sizeFor(collection)]; Iterator iterator = (Iterator)this.containerPolicy.iteratorFor(collection); int index = 0; while(iterator.hasNext()){ Object target = iterator.next(); if (target != null){ CMPPolicy policy = referenceDescriptor.getCMPPolicy(); if (policy != null && policy.isCMP3Policy()){ result[index] = policy.createPrimaryKeyInstance(target, session); }else{ result[index] = referenceDescriptor.getObjectBuilder().extractPrimaryKeyFromObject(target, session); } ++index; } } return result; }
/** * INTERNAL: This method will access the target relationship and create a * list of PKs of the target entities. This method is used in combination * with the CachedValueHolder to store references to PK's to be loaded from * a cache instead of a query. */ public Object[] buildReferencesPKList(Object entity, Object attribute, AbstractSession session) { ClassDescriptor referenceDescriptor = getReferenceDescriptor(); Object target = this.indirectionPolicy.getRealAttributeValueFromObject(entity, attribute); Object[] result = new Object[1]; if (target != null){ CMPPolicy policy = referenceDescriptor.getCMPPolicy(); if (policy != null && policy.isCMP3Policy()) { result[0] = policy.createPrimaryKeyInstance(target, session); } else { result[0] = referenceDescriptor.getObjectBuilder().extractPrimaryKeyFromObject(target, session); } } return result; }
/** * INTERNAL: * Cascade discover and persist new objects during commit. */ public void cascadeDiscoverAndPersistUnregisteredNewObjects(Object object, Map newObjects, Map unregisteredExistingObjects, Map visitedObjects, UnitOfWorkImpl uow, boolean getAttributeValueFromObject, Set cascadeErrors) { Object attributeValue = null; if (getAttributeValueFromObject){ attributeValue = getAttributeValueFromObject(object); } else { attributeValue = object; } if (attributeValue != null && this.indirectionPolicy.objectIsInstantiated(attributeValue)) { if (getAttributeValueFromObject){ attributeValue = this.indirectionPolicy.getRealAttributeValueFromObject(object, attributeValue); } // remove private owned object from uow list if (isCandidateForPrivateOwnedRemoval()) { uow.removePrivateOwnedObject(this, attributeValue); } uow.discoverAndPersistUnregisteredNewObjects(attributeValue, isCascadePersist(), newObjects, unregisteredExistingObjects, visitedObjects, cascadeErrors); } }
/** * INTERNAL: * Cascade discover and persist new objects during commit. */ public void cascadeDiscoverAndPersistUnregisteredNewObjects(Object object, Map newObjects, Map unregisteredExistingObjects, Map visitedObjects, UnitOfWorkImpl uow, boolean getAttributeValueFromObject) { Object attributeValue = null; if (getAttributeValueFromObject){ attributeValue = getAttributeValueFromObject(object); } else { attributeValue = object; } if (attributeValue != null && this.indirectionPolicy.objectIsInstantiated(attributeValue)) { if (getAttributeValueFromObject){ attributeValue = this.indirectionPolicy.getRealAttributeValueFromObject(object, attributeValue); } // remove private owned object from uow list if (isCandidateForPrivateOwnedRemoval()) { uow.removePrivateOwnedObject(this, attributeValue); } uow.discoverAndPersistUnregisteredNewObjects(attributeValue, isCascadePersist(), newObjects, unregisteredExistingObjects, visitedObjects); } }
/** * INTERNAL: * Cascade discover and persist new objects during commit. */ public void cascadeDiscoverAndPersistUnregisteredNewObjects(Object object, Map newObjects, Map unregisteredExistingObjects, Map visitedObjects, UnitOfWorkImpl uow, boolean getAttributeValueFromObject, Set cascadeErrors) { Object attributeValue = null; if (getAttributeValueFromObject){ attributeValue = getAttributeValueFromObject(object); } else { attributeValue = object; } if (attributeValue != null && this.indirectionPolicy.objectIsInstantiated(attributeValue)) { if (getAttributeValueFromObject){ attributeValue = this.indirectionPolicy.getRealAttributeValueFromObject(object, attributeValue); } // remove private owned object from uow list if (isCandidateForPrivateOwnedRemoval()) { uow.removePrivateOwnedObject(this, attributeValue); } uow.discoverAndPersistUnregisteredNewObjects(attributeValue, isCascadePersist(), newObjects, unregisteredExistingObjects, visitedObjects, cascadeErrors); } }
/** * INTERNAL: * Cascade registerNew for Create through mappings that require the cascade * @param object is either the source object, or attribute value if getAttributeValueFromObject is true. */ public void cascadeRegisterNewIfRequired(Object object, UnitOfWorkImpl uow, Map visitedObjects, boolean getAttributeValueFromObject) { if (!isCascadePersist()) { return; } Object attributeValue = null; if (getAttributeValueFromObject) { attributeValue = getAttributeValueFromObject(object); } else { attributeValue = object; } if ((attributeValue != null) // no need to check for new as persist must be cascaded. && (this.indirectionPolicy.objectIsInstantiated(attributeValue) || uow.isCloneNewObject(object))) { if (getAttributeValueFromObject){ attributeValue = this.indirectionPolicy.getRealAttributeValueFromObject(object, attributeValue); } uow.registerNewObjectForPersist(attributeValue, visitedObjects); // add private owned object to uow list if mapping is a candidate and uow should discover new objects and the source object is new. if (isCandidateForPrivateOwnedRemoval() && uow.shouldDiscoverNewObjects() && (attributeValue != null) && uow.isCloneNewObject(object)) { uow.addPrivateOwnedObject(this, attributeValue); } } }