/** * Initialize and set the descriptor for the referenced class in this mapping. */ protected void initializeReferenceDescriptor(AbstractSession session) throws DescriptorException { if (getReferenceClass() == null) { throw DescriptorException.referenceClassNotSpecified(this); } ClassDescriptor refDescriptor = session.getDescriptor(getReferenceClass()); if (refDescriptor == null) { throw DescriptorException.descriptorIsMissing(getReferenceClass().getName(), this); } if (refDescriptor.isAggregateDescriptor() && (!isAggregateCollectionMapping())) { throw DescriptorException.referenceDescriptorCannotBeAggregate(this); } // can not be isolated if it is null. Seems that only aggregates do not set // the owning descriptor on the mapping. setReferenceDescriptor(refDescriptor); }
/** * Initialize and set the descriptor for the referenced class in this mapping. */ protected void initializeReferenceDescriptor(AbstractSession session) throws DescriptorException { if (getReferenceClass() == null) { throw DescriptorException.referenceClassNotSpecified(this); } ClassDescriptor refDescriptor = session.getDescriptor(getReferenceClass()); if (refDescriptor == null) { throw DescriptorException.descriptorIsMissing(getReferenceClass().getName(), this); } if (refDescriptor.isAggregateDescriptor() && (!isAggregateCollectionMapping())) { throw DescriptorException.referenceDescriptorCannotBeAggregate(this); } // can not be isolated if it is null. Seems that only aggregates do not set // the owning descriptor on the mapping. setReferenceDescriptor(refDescriptor); }
/** * Sets the query */ protected void setSelectionQuery(ReadQuery aQuery) { selectionQuery = aQuery; // Make sure the reference class of the selectionQuery is set. if ((selectionQuery != null) && selectionQuery.isObjectLevelReadQuery() && (selectionQuery.getReferenceClassName() == null)) { ((ObjectLevelReadQuery)selectionQuery).setReferenceClass(getReferenceClass()); } }
/** * Sets the query */ protected void setSelectionQuery(ReadQuery aQuery) { selectionQuery = aQuery; // Make sure the reference class of the selectionQuery is set. if ((selectionQuery != null) && selectionQuery.isObjectLevelReadQuery() && (selectionQuery.getReferenceClassName() == null)) { ((ObjectLevelReadQuery)selectionQuery).setReferenceClass(getReferenceClass()); } }
/** * Sets the query */ protected void setSelectionQuery(ReadQuery aQuery) { selectionQuery = aQuery; // Make sure the reference class of the selectionQuery is set. if ((selectionQuery != null) && selectionQuery.isObjectLevelReadQuery() && (selectionQuery.getReferenceClassName() == null)) { ((ObjectLevelReadQuery)selectionQuery).setReferenceClass(getReferenceClass()); } }
/** * INTERNAL: * Return the referenceDescriptor. This is a descriptor which is associated with * the reference class. */ public ClassDescriptor getReferenceDescriptor() { if (referenceDescriptor == null) { if (getTempSession() == null) { return null; } else { referenceDescriptor = getTempSession().getDescriptor(getReferenceClass()); } } return referenceDescriptor; }
/** * INTERNAL: * Return the referenceDescriptor. This is a descriptor which is associated with * the reference class. */ public ClassDescriptor getReferenceDescriptor() { if (referenceDescriptor == null) { if (getTempSession() == null) { return null; } else { referenceDescriptor = getTempSession().getDescriptor(getReferenceClass()); } } return referenceDescriptor; }
/** * INTERNAL: * Return the referenceDescriptor. This is a descriptor which is associated with * the reference class. */ @Override public ClassDescriptor getReferenceDescriptor() { if (referenceDescriptor == null) { if (getTempSession() == null) { return null; } else { referenceDescriptor = getTempSession().getDescriptor(getReferenceClass()); } } return referenceDescriptor; }
/** * Process against the UOW and attempt to load a local copy before going to the shared cache * If null is returned then the calling UOW will instantiate as normal. */ @Override public Object getValue(UnitOfWorkImpl uow) { if (this.references != null && this.references.length != 0){ if (mapping.isCollectionMapping()){ Collection result = uow.getIdentityMapAccessorInstance().getAllFromIdentityMapWithEntityPK(this.references, this.mapping.getReferenceDescriptor()).values(); if (result.size() == references.length){ ContainerPolicy cp = mapping.getContainerPolicy(); Object container = cp.containerInstance(result.size()); for (Object object : result){ cp.addInto(object, container, uow); } return container; } }else{ return uow.getIdentityMapAccessorInstance().getFromIdentityMap(this.references[0], this.mapping.getReferenceClass()); } } return null; }
expectedType = ((ForeignReferenceMapping) mapping).getReferenceClass();
/** * Initialize and set the descriptor for the referenced class in this mapping. */ protected void initializeReferenceDescriptor(AbstractSession session) throws DescriptorException { if (getReferenceClass() == null) { throw DescriptorException.referenceClassNotSpecified(this); } ClassDescriptor refDescriptor = session.getDescriptor(getReferenceClass()); if (refDescriptor == null) { throw DescriptorException.descriptorIsMissing(getReferenceClass().getName(), this); } if (refDescriptor.isAggregateDescriptor() && (!isAggregateCollectionMapping())) { throw DescriptorException.referenceDescriptorCannotBeAggregate(this); } // can not be isolated if it is null. Seems that only aggregates do not set // the owning descriptor on the mapping. if ((!((this.getDescriptor() != null) && this.getDescriptor().isIsolated())) && refDescriptor.isIsolated()) { throw DescriptorException.isolateDescriptorReferencedBySharedDescriptor(refDescriptor.getJavaClassName(), this.getDescriptor().getJavaClassName(), this); } setReferenceDescriptor(refDescriptor); }
/** * Process against the UOW and attempt to load a local copy before going to the shared cache * If null is returned then the calling UOW will instantiate as normal. */ @Override public Object getValue(UnitOfWorkImpl uow) { if (this.references != null && this.references.length != 0){ if (mapping.isCollectionMapping()){ Collection result = uow.getIdentityMapAccessorInstance().getAllFromIdentityMapWithEntityPK(this.references, this.mapping.getReferenceDescriptor()).values(); if (result.size() == references.length){ ContainerPolicy cp = mapping.getContainerPolicy(); Object container = cp.containerInstance(result.size()); for (Object object : result){ cp.addInto(object, container, uow); } return container; } }else{ return uow.getIdentityMapAccessorInstance().getFromIdentityMap(this.references[0], this.mapping.getReferenceClass()); } } return null; }
expectedType = ((ForeignReferenceMapping)mapping).getReferenceClass();
expectedType = ((ForeignReferenceMapping)mapping).getReferenceClass();
private Property buildProperty(PersistenceContext context, DatabaseMapping mapping) { if (mapping.isCollectionMapping()) { final Property property = new Property(); property.setType("array"); property.setItems(buildProperty(context, getCollectionGenericClass(mapping))); return property; } else if (mapping.isForeignReferenceMapping()) { final ForeignReferenceMapping foreignReferenceMapping = (ForeignReferenceMapping)mapping; final String href = HrefHelper.buildEntityMetadataHref(context, foreignReferenceMapping.getReferenceClass().getSimpleName() + "#"); return new Property(href); } else { return buildProperty(context, mapping.getAttributeClassification()); } }
private Property buildProperty(PersistenceContext context, DatabaseMapping mapping) { if (mapping.isCollectionMapping()) { final Property property = new Property(); property.setType("array"); property.setItems(buildProperty(context, getCollectionGenericClass(mapping))); return property; } else if (mapping.isForeignReferenceMapping()) { final ForeignReferenceMapping foreignReferenceMapping = (ForeignReferenceMapping)mapping; final String href = HrefHelper.buildEntityMetadataHref(context, foreignReferenceMapping.getReferenceClass().getSimpleName() + "#"); return new Property(href); } else { return buildProperty(context, mapping.getAttributeClassification()); } }
@Override public Class<?> getAttributeClass() { if (mapping.isForeignReferenceMapping()) { ForeignReferenceMapping refMapping = (ForeignReferenceMapping)mapping; if (refMapping.isCollectionMapping()) { return ((CollectionMapping)refMapping).getContainerPolicy().getContainerClass(); } if (refMapping.usesIndirection()) { return ValueHolderInterface.class; } return refMapping.getReferenceClass(); } else { if (mapping.getAttributeClassification() == null) { return ClassConstants.OBJECT; } return mapping.getAttributeClassification(); } } }
@Override public Class<?> getAttributeClass() { if (mapping.isForeignReferenceMapping()) { ForeignReferenceMapping refMapping = (ForeignReferenceMapping)mapping; if (refMapping.isCollectionMapping()) { return ((CollectionMapping)refMapping).getContainerPolicy().getContainerClass(); } if (refMapping.usesIndirection()) { return ValueHolderInterface.class; } return refMapping.getReferenceClass(); } else { if (mapping.getAttributeClassification() == null) { return ClassConstants.OBJECT; } return mapping.getAttributeClassification(); } } }
/** * This method will lazily initialize the set method * Lazy initialization occurs to that we are not required to have a handle on * the actual class that we are using until runtime. This helps to satisfy the * weaving requirement that demands that we avoid loading domain classes into * the main class loader until after weaving occurs. */ protected Method getSetMethod() { if (setMethod == null) { ForeignReferenceMapping sourceMapping = (ForeignReferenceMapping)mapping; // The parameter type for the set method must always be the return type of the get method. Class[] parameterTypes = new Class[1]; parameterTypes[0] = sourceMapping.getReferenceClass(); try { setMethod = Helper.getDeclaredMethod(sourceMapping.getDescriptor().getJavaClass(), setMethodName, parameterTypes); } catch (NoSuchMethodException e){ throw DescriptorException.errorAccessingSetMethodOfEntity(sourceMapping.getDescriptor().getJavaClass(), setMethodName ,sourceMapping.getDescriptor(), e); } } return setMethod; }
@Override public Class<?> getAttributeClass() { if (getMapping().isForeignReferenceMapping()) { ForeignReferenceMapping refMapping = (ForeignReferenceMapping) getMapping(); if (refMapping.isCollectionMapping()) { return ((CollectionMapping) refMapping).getContainerPolicy().getContainerClass(); } if (refMapping.usesIndirection()) { return ValueHolderInterface.class; } return refMapping.getReferenceClass(); } else { if (getMapping().getAttributeClassification() == null) { return ClassConstants.OBJECT; } return getMapping().getAttributeClassification(); } } }