Community
Participate
Working Groups
Consider the following schema: ... <xs:complexType name="person"> <xs:sequence> <xs:element name="company" type="xs:IDREF"/> </xs:sequence> </xs:complexType> <xs:complexType name="company"> <xs:sequence> <xs:element name="name" type="xs:string"/> </xs:sequence> <xs:attribute name="id" type="xs:ID"/> </xs:complexType> ... The JAXB RI will generate the following Java code: public class Person { @XmlElement(required = true) @XmlIDREF @XmlSchemaType(name = "IDREF") protected Object company; ... } public class Company { @XmlAttribute(namespace = "myNamespace") @XmlJavaTypeAdapter(CollapsedStringAdapter.class) @XmlID @XmlSchemaType(name = "ID") protected String id; ... } Because there is no way to tell what Java type 'company' is, it is typed as Object on the Person class. Since there is no TypeInfo created for Object, we will never generate an XMLObjectReferenceMapping in MappingsGenerator, but instead an XMLCompositeObjectMapping is created instead: MappingsGenerator line 431: TypeInfo reference = typeInfo.get(referenceClass.getQualifiedName()); if (reference != null) { if (property.isXmlIdRef()) { generateXMLObjectReferenceMapping(property, descriptor, namespaceInfo, referenceClass); } else { if (reference.isEnumerationType()) { generateDirectEnumerationMapping(property, descriptor, namespaceInfo, (EnumTypeInfo) reference); } else { generateCompositeObjectMapping(property, descriptor, namespaceInfo, referenceClass.getQualifiedName()); } } We will need to be able to support XMLObjectReferenceMappings that do not have a reference class set.
Created attachment 163823 [details] Core - Fix This patch represents a work in progress. If a reference descriptor is not set on the XMLObjectReferenceMapping then use the session to look up a descriptor. Current Limitations: - Only marshal operation is supported - If a reference descriptor is not set, the target descriptor is assumed to have a single part key.
Created attachment 163824 [details] MOXy - Fix This patch represents a work in progress.
Created attachment 164108 [details] Core - Fix
Created attachment 164246 [details] Core - Fix
Created attachment 164247 [details] MOXy - Fix
Created attachment 164406 [details] Core - Fix
Created attachment 164623 [details] MOXy - Test Cases
Created attachment 164624 [details] Core - Fix
Created attachment 164629 [details] MOXy - Test Cases
Created attachment 164630 [details] Core - Fix
Created attachment 164733 [details] Core - Fix
Created attachment 164734 [details] MOXy - Test Cases
Created attachment 164891 [details] MOXy - Test Cases
Created attachment 164892 [details] Core - Fix
Created attachment 164893 [details] MOXy - Fix
Fix checked into trunk at rev: 6990 We now support null or Object as the reference class on XMLObjectReferenceMapping and XMLCollectionReferenceMapping (see below). Note that when no reference class is set, the mapping is limited to one pk/fk pair. XMLCollectionReferenceMapping phoneNumbersMapping = new XMLCollectionReferenceMapping(); phoneNumbersMapping.setAttributeName("phoneNumbers"); phoneNumbersMapping.addSourceToTargetKeyFieldAssociation("phone-number-id/text()", null); phoneNumbersMapping.setReferenceClass(Object.class); phoneNumbersMapping.getContainerPolicy().setContainerClass(ArrayList.class); xmlDescriptor.addMapping(phoneNumbersMapping); With this type of mapping when the reference is being resolved each cache with a primary key size of 1 will be checked. Code Reviewed By: Rick Barkhouse
Fixed as above.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink