/** * Convenience method. * Return the value of an attribute, unwrapping value holders if necessary. * If the value is null, build a new container. */ public Object getRealCollectionAttributeValueFromObject(Object object, AbstractSession session) throws DescriptorException { Object value = getRealAttributeValueFromObject(object, session); if (value == null) { value = this.containerPolicy.containerInstance(1); } return value; }
/** * Convenience method. * Return the value of an attribute, unwrapping value holders if necessary. * If the value is null, build a new container. */ @Override public Object getRealCollectionAttributeValueFromObject(Object object, AbstractSession session) throws DescriptorException { Object value = getRealAttributeValueFromObject(object, session); if (value == null) { value = this.containerPolicy.containerInstance(1); } return value; }
/** * Convenience method. * Return the value of an attribute, unwrapping value holders if necessary. * If the value is null, build a new container. */ @Override public Object getRealCollectionAttributeValueFromObject(Object object, AbstractSession session) throws DescriptorException { Object value = getRealAttributeValueFromObject(object, session); if (value == null) { value = this.containerPolicy.containerInstance(1); } return value; }
/** * INTERNAL: * Overridden by mappings that require additional processing of the change record after the record has been calculated. */ @Override public void recordPrivateOwnedRemovals(Object object, UnitOfWorkImpl uow) { // no need for private owned check. This code is only registered for private owned mappings. // targets are added to and/or removed to/from the source. if (mustDeleteReferenceObjectsOneByOne()) { Iterator it = (Iterator) containerPolicy.iteratorFor(getRealAttributeValueFromObject(object, uow)); while (it.hasNext()) { Object clone = it.next(); containerPolicy.recordPrivateOwnedRemovals(clone, referenceDescriptor, uow); } } }
/** * INTERNAL: * Overridden by mappings that require additional processing of the change record after the record has been calculated. */ @Override public void recordPrivateOwnedRemovals(Object object, UnitOfWorkImpl uow) { // no need for private owned check. This code is only registered for private owned mappings. // targets are added to and/or removed to/from the source. if (mustDeleteReferenceObjectsOneByOne()) { Iterator it = (Iterator) containerPolicy.iteratorFor(getRealAttributeValueFromObject(object, uow)); while (it.hasNext()) { Object clone = it.next(); containerPolicy.recordPrivateOwnedRemovals(clone, referenceDescriptor, uow); } } }
/** * INTERNAL: * Overridden by mappings that require additional processing of the change record after the record has been calculated. */ @Override public void recordPrivateOwnedRemovals(Object object, UnitOfWorkImpl uow) { // no need for private owned check. This code is only registered for private owned mappings. // targets are added to and/or removed to/from the source. if (mustDeleteReferenceObjectsOneByOne()) { Iterator it = (Iterator) containerPolicy.iteratorFor(getRealAttributeValueFromObject(object, uow)); while (it.hasNext()) { Object clone = it.next(); containerPolicy.recordPrivateOwnedRemovals(clone, referenceDescriptor, uow); } } }
/** * Force instantiation of the load group. */ @Override public void load(final Object object, AttributeItem item, final AbstractSession session, final boolean fromFetchGroup) { instantiateAttribute(object, session); if (item.getGroup() != null && (!fromFetchGroup || session.isUnitOfWork()) ){ //if UOW make sure the nested attributes are loaded as the clones will not be instantiated Object value = getRealAttributeValueFromObject(object, session); ContainerPolicy cp = this.containerPolicy; for (Object iterator = cp.iteratorFor(value); cp.hasNext(iterator);) { Object wrappedObject = cp.nextEntry(iterator, session); Object nestedObject = cp.unwrapIteratorResult(wrappedObject); session.load(nestedObject, item.getGroup(nestedObject.getClass()), getReferenceDescriptor(), fromFetchGroup); } } }
/** * Force instantiation of the load group. */ @Override public void load(final Object object, AttributeItem item, final AbstractSession session, final boolean fromFetchGroup) { instantiateAttribute(object, session); if (item.getGroup() != null && (!fromFetchGroup || session.isUnitOfWork()) ){ //if UOW make sure the nested attributes are loaded as the clones will not be instantiated Object value = getRealAttributeValueFromObject(object, session); ContainerPolicy cp = this.containerPolicy; for (Object iterator = cp.iteratorFor(value); cp.hasNext(iterator);) { Object wrappedObject = cp.nextEntry(iterator, session); Object nestedObject = cp.unwrapIteratorResult(wrappedObject); session.load(nestedObject, item.getGroup(nestedObject.getClass()), getReferenceDescriptor(), fromFetchGroup); } } }
/** * Force instantiation of all indirections. */ @Override public void loadAll(Object object, AbstractSession session, IdentityHashSet loaded) { instantiateAttribute(object, session); ClassDescriptor referenceDescriptor = getReferenceDescriptor(); if (referenceDescriptor != null) { boolean hasInheritance = referenceDescriptor.hasInheritance() || referenceDescriptor.hasTablePerClassPolicy(); Object value = getRealAttributeValueFromObject(object, session); ContainerPolicy cp = this.containerPolicy; for (Object iterator = cp.iteratorFor(value); cp.hasNext(iterator);) { Object wrappedObject = cp.nextEntry(iterator, session); Object nestedObject = cp.unwrapIteratorResult(wrappedObject); if (hasInheritance && !nestedObject.getClass().equals(referenceDescriptor.getJavaClass())){ ClassDescriptor concreteReferenceDescriptor = referenceDescriptor.getInheritancePolicy().getDescriptor(nestedObject.getClass()); concreteReferenceDescriptor.getObjectBuilder().loadAll(nestedObject, session, loaded); } else { referenceDescriptor.getObjectBuilder().loadAll(nestedObject, session, loaded); } } } }
/** * Force instantiation of all indirections. */ @Override public void loadAll(Object object, AbstractSession session, IdentityHashSet loaded) { instantiateAttribute(object, session); ClassDescriptor referenceDescriptor = getReferenceDescriptor(); if (referenceDescriptor != null) { boolean hasInheritance = referenceDescriptor.hasInheritance() || referenceDescriptor.hasTablePerClassPolicy(); Object value = getRealAttributeValueFromObject(object, session); ContainerPolicy cp = this.containerPolicy; for (Object iterator = cp.iteratorFor(value); cp.hasNext(iterator);) { Object wrappedObject = cp.nextEntry(iterator, session); Object nestedObject = cp.unwrapIteratorResult(wrappedObject); if (hasInheritance && !nestedObject.getClass().equals(referenceDescriptor.getJavaClass())){ ClassDescriptor concreteReferenceDescriptor = referenceDescriptor.getInheritancePolicy().getDescriptor(nestedObject.getClass()); concreteReferenceDescriptor.getObjectBuilder().loadAll(nestedObject, session, loaded); } else { referenceDescriptor.getObjectBuilder().loadAll(nestedObject, session, loaded); } } } }
/** * INTERNAL: * We are not using a remote valueholder * so we need to replace the reference object(s) with * the corresponding object(s) from the remote session. */ @Override public void fixRealObjectReferences(Object object, Map objectDescriptors, Map processedObjects, ObjectLevelReadQuery query, DistributedSession session) { //bug 4147755 getRealAttribute... / setReal Object attributeValue = getRealAttributeValueFromObject(object, session); // the object collection could be null, check here to avoid NPE if (attributeValue == null) { setAttributeValueInObject(object, null); return; } ObjectLevelReadQuery tempQuery = query; if (!tempQuery.shouldMaintainCache()) { if ((!tempQuery.shouldCascadeParts()) || (tempQuery.shouldCascadePrivateParts() && (!isPrivateOwned()))) { tempQuery = null; } } Object remoteAttributeValue = session.getObjectsCorrespondingToAll(attributeValue, objectDescriptors, processedObjects, tempQuery, this.containerPolicy); setRealAttributeValueInObject(object, remoteAttributeValue); }
/** * INTERNAL: * We are not using a remote valueholder * so we need to replace the reference object(s) with * the corresponding object(s) from the remote session. */ public void fixRealObjectReferences(Object object, Map objectDescriptors, Map processedObjects, ObjectLevelReadQuery query, RemoteSession session) { //bug 4147755 getRealAttribute... / setReal Object attributeValue = getRealAttributeValueFromObject(object, session); // the object collection could be null, check here to avoid NPE if (attributeValue == null) { setAttributeValueInObject(object, null); return; } ObjectLevelReadQuery tempQuery = query; if (!tempQuery.shouldMaintainCache()) { if ((!tempQuery.shouldCascadeParts()) || (tempQuery.shouldCascadePrivateParts() && (!isPrivateOwned()))) { tempQuery = null; } } Object remoteAttributeValue = session.getObjectsCorrespondingToAll(attributeValue, objectDescriptors, processedObjects, tempQuery, this.containerPolicy); setRealAttributeValueInObject(object, remoteAttributeValue); }
/** * INTERNAL: * We are not using a remote valueholder * so we need to replace the reference object(s) with * the corresponding object(s) from the remote session. */ @Override public void fixRealObjectReferences(Object object, Map objectDescriptors, Map processedObjects, ObjectLevelReadQuery query, DistributedSession session) { //bug 4147755 getRealAttribute... / setReal Object attributeValue = getRealAttributeValueFromObject(object, session); // the object collection could be null, check here to avoid NPE if (attributeValue == null) { setAttributeValueInObject(object, null); return; } ObjectLevelReadQuery tempQuery = query; if (!tempQuery.shouldMaintainCache()) { if ((!tempQuery.shouldCascadeParts()) || (tempQuery.shouldCascadePrivateParts() && (!isPrivateOwned()))) { tempQuery = null; } } Object remoteAttributeValue = session.getObjectsCorrespondingToAll(attributeValue, objectDescriptors, processedObjects, tempQuery, this.containerPolicy); setRealAttributeValueInObject(object, remoteAttributeValue); }
public void setChangeListener(Object clone, PropertyChangeListener listener, UnitOfWorkImpl uow) { if (this.indirectionPolicy.usesTransparentIndirection() && isAttributeValueInstantiated(clone)) { Object attributeValue = getRealAttributeValueFromObject(clone, uow); if (!(attributeValue instanceof CollectionChangeTracker)) { Object container = attributeValue; ((IndirectCollection)getRealAttributeValueFromObject(clone, uow)).clearDeferredChanges();
Object attributeValue = this.getRealAttributeValueFromObject(queryObject, session); if (attributeValue != null && getContainerPolicy().isEmpty(attributeValue)){
public void setChangeListener(Object clone, PropertyChangeListener listener, UnitOfWorkImpl uow) { if (this.indirectionPolicy.usesTransparentIndirection() && isAttributeValueInstantiated(clone)) { Object attributeValue = getRealAttributeValueFromObject(clone, uow); if (!(attributeValue instanceof CollectionChangeTracker)) { Object container = attributeValue; ((IndirectCollection)getRealAttributeValueFromObject(clone, uow)).clearDeferredChanges();
Object attributeValue = this.getRealAttributeValueFromObject(queryObject, session); if (attributeValue != null && getContainerPolicy().isEmpty(attributeValue)){
/** * INTERNAL: * Set the change listener in the collection. * If the collection is not indirect it must be re-built. * This is used for resuming or flushing units of work. */ public void setChangeListener(Object clone, PropertyChangeListener listener, UnitOfWorkImpl uow) { if (this.indirectionPolicy.usesTransparentIndirection() && isAttributeValueInstantiated(clone)) { Object attributeValue = getRealAttributeValueFromObject(clone, uow); if (!(attributeValue instanceof CollectionChangeTracker)) { Object container = attributeValue; ContainerPolicy containerPolicy = this.containerPolicy; if (attributeValue == null) { container = containerPolicy.containerInstance(1); } else { container = containerPolicy.containerInstance(containerPolicy.sizeFor(attributeValue)); for (Object iterator = containerPolicy.iteratorFor(attributeValue); containerPolicy.hasNext(iterator);) { containerPolicy.addInto(containerPolicy.nextEntry(iterator, uow), container, uow); } } setRealAttributeValueInObject(clone, container); ((CollectionChangeTracker)container).setTrackedAttributeName(getAttributeName()); ((CollectionChangeTracker)container)._persistence_setPropertyChangeListener(listener); } else { ((CollectionChangeTracker)attributeValue).setTrackedAttributeName(getAttributeName()); ((CollectionChangeTracker)attributeValue)._persistence_setPropertyChangeListener(listener); } } }