users@jaxb.java.net

Re: Re: Subclassing JAXB 2.0-generated classes

From: Dmitri Colebatch <dim_at_colebatch.com>
Date: Fri, 14 Jul 2006 07:02:57 +1000

Am I right in assuming that you have the annotion on your overriding
method in the subclass? If so, remove it.

cheers
dim

On 7/14/06, Pelenur, Matias <pelenur_at_amazon.com> wrote:
> I tried moving the @XmlElement(name = "subElement") annotation from the field to the accesor method, but while unmarshalling an IllegalAnnotationsException is thrown (attached). There seems to be a conflict between having both the field and the accessor, even though the field does not have the annotation anymore.
>
> If I comment-out the field and leave the accessor method only (with the annotation), then the unmarshaller ends up calling setSubElements() and passes it the list returned by getSubElements(), which seems a bit redundant. Other than that it seems to work.
>
> --matias
>
> > -----Original Message-----
> > From: Kohsuke Kawaguchi [mailto:Kohsuke.Kawaguchi_at_Sun.COM]
> > Sent: Wednesday, July 12, 2006 5:05 PM
> > To: users_at_jaxb.dev.java.net
> > Subject: Re: Subclassing JAXB 2.0-generated classes
> >
> > Pelenur, Matias wrote:
> > > I see. Is there a way then to annotate the original XSD so that the
> > > generated classes put the annotation on the method instead
> > of the field?
> >
> > What makes this tricky is that it's not always possible to
> > use methods.
> > Sometimes methods have some side effect that interferes with
> > marshalling/unmarshalling --- for example, "int getFoo()"
> > might return a
> > default value when no value is set.
> >
> > So this is hard to do in general.
> >
> > Maybe we can allow it to be configured per property by customization?
> >
> > Can you first check if moving annotation to the method would
> > really work
> > :-) ?
> >
> > --
> > Kohsuke Kawaguchi
> > Sun Microsystems kohsuke.kawaguchi_at_sun.com
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>
>