users@jaxb.java.net

Re: Subclassing JAXB 2.0-generated classes

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Wed, 12 Jul 2006 16:27:00 -0700

Pelenur, Matias wrote:
> @XmlElement(name = "someSubElement")
> protected List<SomeSubElement> someSubElements;
>
> However, it doesn't seem like the unmarshaller ever calls the
> getSomeSubElements() method that was overriden; instead, it seems to
> directly access the someSubElements member variable (of the generated
> class) and populate it. This happens even though the unmarshaller does
> get an instance of my subclass correctly (from my ObjectFactory
> subclass).

Right. This is because the annotation is on a field, not on a method.
Placing this on a method would cause unmarshaller to invoke them.

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com