Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] XML Object Reference Mapping

During debugging I noticed that IndustrialFamily had no primary key (code). This was giving the exception. I could not define a primary key for IndustrialFamily in the workbench. Is this currently not supported?

I tried to workaround this problem using afterload methods and doing this in Java.

This is my code:

public static void afterFamilyLoader(ClassDescriptor familyDescriptor) {
       familyDescriptor.setJavaClass(IndustrialFamily.class);
       familyDescriptor.addPrimaryKeyFieldName("@code");
   }
public static void afterProductLoader(ClassDescriptor productDescriptor) {
       XMLObjectReferenceMapping product = new XMLObjectReferenceMapping();
       product.setAttributeName("industrialFamily");
       product.setReferenceClass(IndustrialFamily.class);
product.addSourceToTargetKeyFieldAssociation("@familyCode", "@code");
       productDescriptor.addMapping(product);
   }

I don't get a stacktrace any more. But now the family is null in my Product Object.
Is there still something missing in my mapping?

Leon





Leon Derks wrote:
Hello

I have a problem (stacktrace) using the XML Object Reference Mapping in the workbench tool from EclipseLink 1.0M6.

This is my xml data:

<CatalogProduct code="123JI" name="BSN Lamp" type="Lamp" familyCode="BSN-BC4H">

.....

</CatalogProduct>

<IndustrialFamilies>

<IndustrialFamily code="BSN-BC4H" name="Family Lamps" productCategoryCode="Lamps"/>

</IndustrialFamilies>

I mapped this in the workbench as an XML Object Reference with Source Xpath=@familyCode and Target Xpath=@code.

In the eclipselink documentation I read that XML Object Reference is only supported in Java and not in the workbench. Is this still the case?

Running an unmarshall application in Eclipse, results in the following stacktrace:


javax.xml.bind.UnmarshalException

- with linked exception:

[java.lang.ArrayIndexOutOfBoundsException: -1]

at org.eclipse.persistence.jaxb.JAXBUnmarshaller.unmarshal(JAXBUnmarshaller.java:102)

at com.philips.lighting.research.jaxb.UnmarshallXml.main(UnmarshallXml.java:31)

Caused by: java.lang.ArrayIndexOutOfBoundsException: -1

    at java.util.Vector.setElementAt(Unknown Source)

at org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping.buildReference(XMLObjectReferenceMapping.java:147)

at org.eclipse.persistence.internal.oxm.XMLObjectReferenceMappingNodeValue.attribute(XMLObjectReferenceMappingNodeValue.java:91)

at org.eclipse.persistence.oxm.record.UnmarshalRecord.startElement(UnmarshalRecord.java:600)

at org.eclipse.persistence.internal.oxm.XMLRelationshipMappingNodeValue.processChild(XMLRelationshipMappingNodeValue.java:72)

at org.eclipse.persistence.internal.oxm.XMLCompositeCollectionMappingNodeValue.startElement(XMLCompositeCollectionMappingNodeValue.java:89)

at org.eclipse.persistence.oxm.record.UnmarshalRecord.startElement(UnmarshalRecord.java:558)

at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)

at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)

at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)

at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)

at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)

at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)

at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)

at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)

at org.eclipse.persistence.internal.oxm.record.XMLReader.parse(XMLReader.java:99)

at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:216)

at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:193)

at org.eclipse.persistence.oxm.XMLUnmarshaller.unmarshal(XMLUnmarshaller.java:274)

at org.eclipse.persistence.jaxb.JAXBUnmarshaller.unmarshal(JAXBUnmarshaller.java:100)

    ... 1 more


_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users





Back to the top