users@jaxb.java.net

Re: Java inheritance

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Tue, 11 Jul 2006 15:42:10 -0700

David Blevins wrote:
> These two posts seem to detail quite nicely what I'm facing.
>
> https://jaxb.dev.java.net/servlets/ReadMsg?list=users&msgNo=4111
> https://jaxb.dev.java.net/servlets/ReadMsg?listName=users&msgNo=4252
>
> In short, I've generated a JAXB2 annotated Java tree from the Java EE
> 5 ejb-jar xsd and would now like to introduce a superclass
> (EnterpriseBean) for EntityBeanType, MessageDrivenBeanType and
> SessionBeanType as 80% of their properties are the same.
>
> I'm finding this to be an impossible task as declaring the propOrder
> in the subclass results in the "..._at_XmlType.propOrder... no such
> property exists" exception and declaring a @XmlType.propOrder in the
> superclass gives me the wrong order in xml.
>
> What will it take to support this feature? I understand there may be
> issues, but I'm almost certain i'd prefer those issues over this one.

One of the things that we are discussing toward JAXB 2.1 is to have the
notion of "not mapping super class" then you can do something like:

@XmlTransient abstract class EnterpriseBean {
   get/setA();
   get/setC();
}

@XmlType(propOrder={"a","b","c"})
class EntityBeanType extends EnterpriseBean {
   get/setB();
}

the same with MessageDrivenBeanType and SessionBeanType.

Would this feature make you happy?

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com