users@jaxb.java.net

RE: Re: Re: Subclassing JAXB 2.0-generated classes

From: Pelenur, Matias <pelenur_at_amazon.com>
Date: Thu, 13 Jul 2006 14:09:41 -0700

No, the annotation is only in the generated class, not in the subclass.

-matias

> -----Original Message-----
> From: colebatchd_at_gmail.com [mailto:colebatchd_at_gmail.com] On
> Behalf Of Dmitri Colebatch
> Sent: Thursday, July 13, 2006 2:03 PM
> To: users_at_jaxb.dev.java.net
> Subject: Re: Re: Subclassing JAXB 2.0-generated classes
>
> 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
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>