JAXB and property ordering

It's possible using:

@XmlType (propOrder={"prop1","prop2",..."propN"})

Just uncomment the code like this:

//@XmlType(propOrder={"company", "scheme", "agreementNumber"})

This is the correct usage.


Note: I lead EclipseLink JAXB (MOXy)

The order in which Java reflection returns the list of fields/properties is not guaranteed. This is why JAXB implementations do not use it to determine element order.

By default JAXB provides no guaranteed ordering. However most (if not all JAXB implementations) use alphabetical ordering since it is deterministic. To guarantee this ordering you must annotate your class as follows:

@XmlAccessorOrder(XmlAccessOrder.ALPHABETICAL)
public class Foo {
    ...
}

@XmlType(propOrder={"company", "scheme", "agreementNumber"})

It's correct, but have you tried this?

@XmlType(propOrder={"Company", "Scheme", "AgreementNumber"})