users@jaxb.java.net

Re: Hyperjaxb3 association customization

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Tue, 19 Jan 2010 17:01:29 +0100

Hi,

Please use users_at_hyperjaxb.dev.java.net ML for HJ questions.

> I'm stuck trying to customize a one-to-many association. I'd like to reduce
> the cascadetype from 'all' to just all-'delete'. I'm using maven with the
> hyperjaxb3 plugin, version 0.5.4.
>
>
> Schema snippet:
> ...
> <xs:complexType name="Category">
> <xs:choice maxOccurs="unbounded">
> <xs:element name="element1" type="...">
> <xs:element name="element2" type="...">
> <xs:element name="element3" type="...">
> </xs:choice>
> </xs:complexType>
> ...
>
> My external customization is:
> ...
> <jxb:bindings node="//xs:complexType[@name='Category']/xs:choice">
> <hj:one-to-many>
> <orm:join-column />
> <orm:cascade>
> <orm:cascade-persist />
> <orm:cascade-refresh />
> <orm:cascade-merge />
> </orm:cascade>
> </hj:one-to-many>
> </jxb:bindings>
> ...
>
> All I'm getting is this error message: "com.sun.istack.SAXParseException2:
> compiler was unable to honor this hj:one-to-many customization. It is
> attached to a wrong place, or its inconsistent with other bindings."
>
> Could anybody please point to my hopefully blatant error?

The problem is in xs:choice/_at_maxOccurs="unbounded". This produces a
heterogeneous list and HJ3 must create additional classes to wrap this
construct. When creating these classes, customizations are apparently
not propagated. I'd say it is a missing feature.

I would advise to reconsider the usage
xs:choice/_at_maxOccurs="unbounded" - you will en up with something ugly
in ORM in almost any case. Apart from that, please feel free to file
an issue about lost customizations in HJ3 JIRA:

http://jira.highsource.org/browse/HJIII

Gruss,
/lexi