users@jaxb.java.net

Re: subclasses, annotation inheritance and propOrder

From: Dmitri Colebatch <colebatchd_at_gmail.com>
Date: Thu, 23 Jun 2005 10:08:33 +1000

On 6/23/05, Sekhar Vajjhala <Sekhar.Vajjhala_at_sun.com> wrote:

> @XmlType.propOrder can only contain fields/properties declared within a
> class not those
> in its super class.

Yeah I can see that, but I don't understand why that logic should be enforced.

The penny has just dropped for me with this - if in my example I don't
include givenName and surname in the propOrder of FullName, then the
element order is givenName,surname, title, middleName. So we have the
supertype's elements first, and then the extension's elements second.
I assume this is done this way because thats the way that xml schema
works - that's the thing I was forgetting. I was looking at it from a
java perspective.

> you are getting doubling up because class Name is also being mapped since
> FullName derives from it. To avoid doubling up, you can mark the fields or
> properties (depending upon what you are mapping) with @XmlTransient in
> the class Name. For e.g.
>
> public class Name {
> @XmlTransient String givenName;
> @XmlTransient String surname;
> ...
> }

Thanks for the work around - I'll give it a go.

cheers
dim