Community
Participate
Working Groups
Build Identifier: 2.3.0-SNAPSHOT (20110202.060516-27) If the class with superclass is annotated with @XmlType(propOrder={...}) and the propOrder contains superclass properties (important, not in the beginning, f.e. propOrder={"superclassProp","classProp",...,"classLastProp"} works), the following exception is thrown: org.eclipse.persistence.exceptions.JAXBException Exception Description: The property or field superclassProp was specified in propOrder but is not a valid property. I traced the issue into AnnotationProcessor.validatePropOrderForInfo(TypeInfo info), more specifically if (!nextPropName.equals(EMPTY_STRING) && !info.getPropertyNames().contains(nextPropName)) Apparently, superclass properties are not added into the class properties. Therefore, the IF statement above must fail. I don't know if such behavior works for generating schema, but it doesn't work for the serialization. I tried a workaround - overriding getter for the superclass property such as: @Override public String getSuperclassProp() { return super.getSuperclassProp(); } The exception is not thrown anymore but it still doesn't work (which makes sense because the superclass properties are not part of the class). In the case of simple classes, the propOrder is not applied, in not-so-simple classes it duplicates the superclass properties like: <Class> <superClassProp>...</superClassProp> <classProp>...</classProp> .... <superClassProp>...</superClassProp> <!-- right position, but duplicated above --> ... Reproducible: Always
I've just figured out a workaround. Removing @XmlElement annotation from superclass and instead place it on the overridden getter like this: @Override @XmlElement(name = "superClassProp") public boolean isInvalid() { return super.isInvalid(); } Then the propOrder is applied correctly.
Created attachment 195145 [details] MOXy - Test Cases
MOXy is working as expected: Scenario #1 - Parent class is marked with @XmlTrasient If the parent class is marked with @XmlTransient then the parent's properties can be included in the @XmlType(propOrder={...}) setting. Scenario #2 - Parent class is not marked with @XmlTransient If the parent class is not marked with @XmlTransient then then the parent's properties can not be in propOrder set on the child class. When inheritance is mapped the parents properties must appear before the childs properties. A set of test cases have been checked in to verify this behaviour.
Test cases checked into trunk at rev: 9340
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink