You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by David Goodenough <da...@btconnect.com> on 2008/04/29 14:30:10 UTC

How to prebuild cascade types

I want to have a single consistent cascade policy right through my
application (or at least as a default that I can override only when needed).

The standard enum allows for either specific operations, or ALL.

So I through OK, lets declare a global variable as an array of CascadeType
enums:-

CascadeType[]defaultCascade = {CascadeType.PERSIST,
     CascadeType.MERGE,CascadeType.REFRESH};

and reference it in the annotations:-

@ManyToOne(cascade=defaultCascade)

but of course the annotation is a compile time thing, and I don't think
that it can reach defaultCascade (even if it is final and static).

Anyone got any ideas as to how to do this?

David

Re: How to prebuild cascade types

Posted by Jan Kotek <op...@gmail.com>.
Maybe you can subclass CascadeType enum?

On 4/29/08, Patrick Linskey <pl...@gmail.com> wrote:
> Hi,
>
>  Note that you can turn on CascadeType.PERSIST across the board (but can't
> subsequently turn it off) by setting the
> persistence-unit-defaults/cascade-persist element in
> orm.xml to true.
>
>  -Patrick
>
>
>  On Apr 29, 2008, at 5:30 AM, David Goodenough wrote:
>
>
> > I want to have a single consistent cascade policy right through my
> > application (or at least as a default that I can override only when
> needed).
> >
> > The standard enum allows for either specific operations, or ALL.
> >
> > So I through OK, lets declare a global variable as an array of CascadeType
> > enums:-
> >
> > CascadeType[]defaultCascade = {CascadeType.PERSIST,
> >    CascadeType.MERGE,CascadeType.REFRESH};
> >
> > and reference it in the annotations:-
> >
> > @ManyToOne(cascade=defaultCascade)
> >
> > but of course the annotation is a compile time thing, and I don't think
> > that it can reach defaultCascade (even if it is final and static).
> >
> > Anyone got any ideas as to how to do this?
> >
> > David
> >
>
>  --
>  Patrick Linskey
>  202 669 5907
>
>

RE: How to prebuild cascade types

Posted by Michael Vorburger <mv...@odyssey-group.com>.
Is there a way to do this without orm.xml, e.g. in persistence.xml?  Or
can you specify an orm.xml with for this, and leave the rest of mapping
metadata in annotations? 


-----Original Message-----
From: Patrick Linskey [mailto:plinskey@gmail.com] 
Sent: mardi, 29. avril 2008 16:43
To: users@openjpa.apache.org
Subject: Re: How to prebuild cascade types

Hi,

Note that you can turn on CascadeType.PERSIST across the board (but
can't subsequently turn it off) by setting the persistence-unit-
defaults/cascade-persist element in orm.xml to true.

-Patrick

On Apr 29, 2008, at 5:30 AM, David Goodenough wrote:

> I want to have a single consistent cascade policy right through my 
> application (or at least as a default that I can override only when 
> needed).
>
> The standard enum allows for either specific operations, or ALL.
>
> So I through OK, lets declare a global variable as an array of 
> CascadeType
> enums:-
>
> CascadeType[]defaultCascade = {CascadeType.PERSIST,
>     CascadeType.MERGE,CascadeType.REFRESH};
>
> and reference it in the annotations:-
>
> @ManyToOne(cascade=defaultCascade)
>
> but of course the annotation is a compile time thing, and I don't 
> think that it can reach defaultCascade (even if it is final and 
> static).
>
> Anyone got any ideas as to how to do this?
>
> David

--
Patrick Linskey
202 669 5907


____________________________________________________________

� This email and any files transmitted with it are CONFIDENTIAL and intended
  solely for the use of the individual or entity to which they are addressed.
� Any unauthorized copying, disclosure, or distribution of the material within
  this email is strictly forbidden.
� Any views or opinions presented within this e-mail are solely those of the
  author and do not necessarily represent those of Odyssey Financial
Technologies SA unless otherwise specifically stated.
� An electronic message is not binding on its sender. Any message referring to
  a binding engagement must be confirmed in writing and duly signed.
� If you have received this email in error, please notify the sender immediately
  and delete the original.

Re: How to prebuild cascade types

Posted by Patrick Linskey <pl...@gmail.com>.
Hi,

Note that you can turn on CascadeType.PERSIST across the board (but  
can't subsequently turn it off) by setting the persistence-unit- 
defaults/cascade-persist element in orm.xml to true.

-Patrick

On Apr 29, 2008, at 5:30 AM, David Goodenough wrote:

> I want to have a single consistent cascade policy right through my
> application (or at least as a default that I can override only when  
> needed).
>
> The standard enum allows for either specific operations, or ALL.
>
> So I through OK, lets declare a global variable as an array of  
> CascadeType
> enums:-
>
> CascadeType[]defaultCascade = {CascadeType.PERSIST,
>     CascadeType.MERGE,CascadeType.REFRESH};
>
> and reference it in the annotations:-
>
> @ManyToOne(cascade=defaultCascade)
>
> but of course the annotation is a compile time thing, and I don't  
> think
> that it can reach defaultCascade (even if it is final and static).
>
> Anyone got any ideas as to how to do this?
>
> David

-- 
Patrick Linskey
202 669 5907