Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-dev] Use of @XmlID/@XmlIDRef when key is in superclass

Hello,

You may be hitting the following issue which has already been fixed in the EclipseLink 2.4.2 and 2.5.0 streams:
These streams have not released yet, but you can obtain pre-release builds from the following locations:
-Blaise


On 12-11-06 8:45 PM, tomlee wrote:
I'm using @XmlID and @XmlIDRef to annotate a reference in the conventional
way as described in a number of places. However, the @XmlID field is in a
superclass of the class of the object being referenced. The generated schema
looks correct. However, I get an error when unmarshalling such a reference.
The error occurs regardless of whether the @XmlID is an element or an
attribute, and regardless of the whether the referenced object occurs first
in the unmarshalled file.

1. Is this supported?
2. The specific error I get with the EclipseLink 2.4.1 plugin is as follows.
In a nutshell it looks like the XMLField.getXPath() of the reference is
wrong (it omits the subclass that contains the reference).  Here's the file
being unmarshalled:

<?xml version="1.0" encoding="UTF-8"?>
<models xmlns="my.url.model">
   <nodes>
      <node elementId="Node_2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Node">
      </node>
      <node elementId="Node_1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Node">
         <successor>Node_2</successor>
      </node>
   </nodes>
</models>

Here is the relevant part of the schema:

   <xsd:complexType name="node" abstract="true">
      <xsd:complexContent>
         <xsd:extension base="ns0:element">
            <xsd:sequence>
               <xsd:element name="successor" type="xsd:IDREF"
minOccurs="0"/>
            </xsd:sequence>
         </xsd:extension>
      </xsd:complexContent>
   </xsd:complexType>
   <xsd:complexType name="element" abstract="true">
      <xsd:attribute name="elementId" type="xsd:ID"/>
   </xsd:complexType>

And here is the exception:

Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
	at
org.eclipse.persistence.internal.identitymaps.CacheId.set(CacheId.java:62)
	at
org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping.buildReference(XMLObjectReferenceMapping.java:184)
	at
org.eclipse.persistence.internal.oxm.XMLObjectReferenceMappingNodeValue.endElement(XMLObjectReferenceMappingNodeValue.java:123)
	at
org.eclipse.persistence.oxm.record.UnmarshalRecord.endElement(UnmarshalRecord.java:968)
	at
org.eclipse.persistence.internal.oxm.record.XMLStreamReaderReader.parseEvent(XMLStreamReaderReader.java:146)
	at
org.eclipse.persistence.internal.oxm.record.XMLStreamReaderReader.parse(XMLStreamReaderReader.java:100)
	at
org.eclipse.persistence.internal.oxm.record.XMLStreamReaderReader.parse(XMLStreamReaderReader.java:87)
	at
org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:827)
	... 28 more




--
View this message in context: http://eclipse.1072660.n5.nabble.com/Use-of-XmlID-XmlIDRef-when-key-is-in-superclass-tp155568.html
Sent from the EclipseLink - Dev mailing list archive at Nabble.com.
_______________________________________________
eclipselink-dev mailing list
eclipselink-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev

Back to the top