/** * 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); }
/** * 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); }
/** * Build an XMLInverseMapping based on a particular mapping and replace that mapping with * the newly created XMLInverseMapping in jaxbDescriptor * @param jaxbDescriptor * @param mapping * @param mappedBy */ private static void convertMappingToXMLInverseReferenceMapping(ClassDescriptor jaxbDescriptor, DatabaseMapping mapping, ForeignReferenceMapping jpaMapping) { if ((mapping != null) && (jaxbDescriptor != null)) { if (!(mapping.isXMLMapping())) { return; } if ((jpaMapping.isAggregateCollectionMapping()) || (jpaMapping.isAggregateMapping())) { return; } XMLInverseReferenceMapping jaxbInverseMapping = new XMLInverseReferenceMapping(); copyAccessorToMapping(mapping, jaxbInverseMapping); jaxbInverseMapping.setProperties(mapping.getProperties()); jaxbInverseMapping.setIsReadOnly(mapping.isReadOnly()); jaxbInverseMapping.setMappedBy(jpaMapping.getAttributeName()); if (mapping.isAbstractCompositeCollectionMapping()) { jaxbInverseMapping.setContainerPolicy(mapping.getContainerPolicy()); jaxbInverseMapping.setReferenceClass(((XMLCompositeCollectionMapping) mapping).getReferenceClass()); } else if (mapping.isAbstractCompositeObjectMapping()) { jaxbInverseMapping.setReferenceClass(((XMLCompositeObjectMapping) mapping).getReferenceClass()); } jaxbDescriptor.removeMappingForAttributeName(mapping.getAttributeName()); jaxbDescriptor.addMapping(jaxbInverseMapping); } }
/** * Build an XMLInverseMapping based on a particular mapping and replace that mapping with * the newly created XMLInverseMapping in jaxbDescriptor * @param jaxbDescriptor * @param mapping * @param mappedBy */ private static void convertMappingToXMLInverseReferenceMapping(ClassDescriptor jaxbDescriptor, DatabaseMapping mapping, ForeignReferenceMapping jpaMapping) { if ((mapping != null) && (jaxbDescriptor != null)) { if (!(mapping.isXMLMapping())) { return; } if ((jpaMapping.isAggregateCollectionMapping()) || (jpaMapping.isAggregateMapping())) { return; } XMLInverseReferenceMapping jaxbInverseMapping = new XMLInverseReferenceMapping(); copyAccessorToMapping(mapping, jaxbInverseMapping); jaxbInverseMapping.setProperties(mapping.getProperties()); jaxbInverseMapping.setIsReadOnly(mapping.isReadOnly()); jaxbInverseMapping.setMappedBy(jpaMapping.getAttributeName()); if (mapping.isAbstractCompositeCollectionMapping()) { jaxbInverseMapping.setContainerPolicy(mapping.getContainerPolicy()); jaxbInverseMapping.setReferenceClass(((XMLCompositeCollectionMapping) mapping).getReferenceClass()); } else if (mapping.isAbstractCompositeObjectMapping()) { jaxbInverseMapping.setReferenceClass(((XMLCompositeObjectMapping) mapping).getReferenceClass()); } jaxbDescriptor.removeMappingForAttributeName(mapping.getAttributeName()); jaxbDescriptor.addMapping(jaxbInverseMapping); } }