users@jaxb.java.net

Re: why Hyperjaxb3 generate cascadetype.all automatically?

From: Tongchun Jiang <tongchun.jiang_at_googlemail.com>
Date: Fri, 11 Mar 2011 15:09:38 +0100

Hi

Thanks. Now it's working!!

and the customization is <hj:many-to-one merge="false" ...>, not "merged"..

Kind Regards / Mit freundlichen Grüßen
----------------------------------------------------------
Tongchun Jiang (Mr.)
Communication and Media Engineering (CME3)
Hochschule Offenburg
Germany



On Fri, Mar 11, 2011 at 2:48 PM, Aleksei Valikov <valikov_at_gmx.net> wrote:

> Hi,
>
> > I want to customize the CascadeType for a many-to-one relationship. I
> dont
> > want the associated Role to be deleted when one User is deleted. So I did
> > the customization as:
> > <jaxb:bindings
> > node="xsd:complexType[@name='user']//xsd:element[@name='role']">
> > <hj:many-to-one>
> > <orm:join-column name="ROLEID" nullable="false" />
> > <orm:cascade>
> > <orm:cascade-persist />
> > <orm:cascade-refresh />
> > <orm:cascade-merge />
> > </orm:cascade>
> > </hj:many-to-one>
> > </jaxb:bindings>
> > But HJ3 generated the following annotation:
> > @ManyToOne(targetEntity = Role.class, cascade = {
> > CascadeType.MERGE,
> > CascadeType.PERSIST,
> > CascadeType.REFRESH,
> > CascadeType.ALL
> > })
> > Why CascadeType.ALL is also there? Isn't it a conflict?
>
> Your customization gets "merged" with the "default" customizations
> (see
> ejb\plugin\src\main\resources\org\jvnet\hyperjaxb3\ejb\strategy\customizing\impl\DefaultCustomizations.xml).
> Merging is useful so that you don't have to provide all the elements
> when you customize.
>
> If you don't want this merging use merged="false", something like:
>
> <hj:many-to-one merged="false" ...>
>
> > I'm thinking to use Annotate plugin to remove this addtional annotation.
> Is
> > this plugin capable to do it?
>
> No, it can't.
>
> Bye,
> /lexi
>