You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Michael Dick <mi...@gmail.com> on 2009/08/24 18:08:26 UTC

Re: Superfluous Updates for a @ManyToOne in OpenJPA 1.2.1

Hi Christopher,
I haven't verified this is the case, but it looks likely - the testcase for
OPENJPA-843 passes when I use the enhancer.

It may also be worth noting that we recently changed the default option for
RuntimeUnenhancedClasses from supported to unsupported in OPENJPA-651. The
change affects trunk and 1.3 (IIRC) and was done to try and prevent users
from falling into situations like this one where the unenhanced classes
don't work properly.

-mike

On Fri, Aug 21, 2009 at 6:49 PM, Christopher Gardner <
chris.r.gardner@gmail.com> wrote:

> So if you don't use the PCEnhancer, the full object graph will be updated?
>  Ouch!
>
> On Fri, Aug 21, 2009 at 6:18 PM, Christopher Gardner <
> chris.r.gardner@gmail.com> wrote:
>
> > I'm not enhancing the classes in any way.  BTW, I'm running outside of a
> > JEE container.
> >
> >
> > On Fri, Aug 21, 2009 at 5:40 PM, Michael Dick <michael.d.dick@gmail.com
> >wrote:
> >
> >>
> >> That's embarrassing - it's right in the subject..
> >>
> >> By any chance are you using RuntimeUnenhancedClasses (if you're running
> >> the
> >> PCEnhancer then you're not and it _should_ all work). If you are then
> >> trying
> >> runtime enhancement might help.
> >>
> >> Sorry for missing the subject earlier.
> >>
> >> -mike
> >>
> >>
> >> Christopher Gardner wrote:
> >> >
> >> > 1.2.1
> >> >
> >> > On Fri, Aug 21, 2009 at 5:24 PM, Michael Dick
> >> > <mi...@gmail.com>wrote:
> >> >
> >> >>
> >> >> Which version of OpenJPA are you using?
> >> >>
> >> >> This sounds like  http://issues.apache.org/jira/browse/OPENJPA-843
> >> >> OPENJPA-843 .
> >> >>
> >> >> -mike
> >> >>
> >> >>
> >> >> Christopher Gardner wrote:
> >> >> >
> >> >> > No matter what value I set cascade to, the update statement
> prevails.
> >> >> > Here
> >> >> > is the last setting.  I've tried every value.
> >> >> > class A {
> >> >> > @ManyToOne(optional = false, cascade = CascadeType.REMOVE)
> >> >> > @JoinColumn(name
> >> >> > = "b_id")
> >> >> >     private B b;
> >> >> > }
> >> >> >
> >> >> > On Fri, Aug 21, 2009 at 4:54 PM, Christopher Gardner <
> >> >> > chris.r.gardner@gmail.com> wrote:
> >> >> >
> >> >> >> What value of the cascade type do you set?
> >> >> >>
> >> >> >>
> >> >> >> On Fri, Aug 21, 2009 at 4:42 PM, C N Davies <cn...@cndavies.com>
> >> wrote:
> >> >> >>
> >> >> >>> I just set cascade type on the field that I don't update but want
> >> the
> >> >> >>> join
> >> >> >>> to be persisted.
> >> >> >>>
> >> >> >>> -----Original Message-----
> >> >> >>> From: Christopher Gardner [mailto:chris.r.gardner@gmail.com]
> >> >> >>> Sent: Saturday, 22 August 2009 3:25 AM
> >> >> >>> To: users@openjpa.apache.org
> >> >> >>> Subject: Superfluous Updates for a @ManyToOne in OpenJPA 1.2.1
> >> >> >>>
> >> >> >>> Class A has a unidirectional many-to-one relationship with Class
> B.
> >> >> I
> >> >> >>> change a property on a Class A object and persist the object.
>  The
> >> >> log
> >> >> >>> shows
> >> >> >>> SQL update statements called for both A and B.  I have no cascade
> >> >> >>> options
> >> >> >>> set on A's @ManyToOne.  I do not want any updates to B because
> it's
> >> >> not
> >> >> >>> logical to do so and it's inefficient. B represents standard,
> >> >> >>> boilerplate
> >> >> >>> data for many A's.  Also, it adds no value for B to know about A.
> >>  No
> >> >> >>> update
> >> >> >>> is appropriate in this context.  How do I stop updates to B?
> >> >> >>>
> >> >> >>>
> >> >> >>
> >> >> >
> >> >> >
> >> >>
> >> >> --
> >> >> View this message in context:
> >> >>
> >>
> http://n2.nabble.com/Superfluous-Updates-for-a-ManyToOne-in-OpenJPA-1-2-1-tp3492419p3492691.html
> >> >> Sent from the OpenJPA Users mailing list archive at Nabble.com.
> >> >>
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://n2.nabble.com/Superfluous-Updates-for-a-ManyToOne-in-OpenJPA-1-2-1-tp3492419p3492745.html
> >> Sent from the OpenJPA Users mailing list archive at Nabble.com.
> >>
> >
> >
>

Re: Superfluous Updates for a @ManyToOne in OpenJPA 1.2.1

Posted by Christopher Gardner <ch...@gmail.com>.
Thanks, Mike.

On Mon, Aug 24, 2009 at 12:08 PM, Michael Dick <mi...@gmail.com>wrote:

> Hi Christopher,
> I haven't verified this is the case, but it looks likely - the testcase for
> OPENJPA-843 passes when I use the enhancer.
>
> It may also be worth noting that we recently changed the default option for
> RuntimeUnenhancedClasses from supported to unsupported in OPENJPA-651. The
> change affects trunk and 1.3 (IIRC) and was done to try and prevent users
> from falling into situations like this one where the unenhanced classes
> don't work properly.
>
> -mike
>
> On Fri, Aug 21, 2009 at 6:49 PM, Christopher Gardner <
> chris.r.gardner@gmail.com> wrote:
>
> > So if you don't use the PCEnhancer, the full object graph will be
> updated?
> >  Ouch!
> >
> > On Fri, Aug 21, 2009 at 6:18 PM, Christopher Gardner <
> > chris.r.gardner@gmail.com> wrote:
> >
> > > I'm not enhancing the classes in any way.  BTW, I'm running outside of
> a
> > > JEE container.
> > >
> > >
> > > On Fri, Aug 21, 2009 at 5:40 PM, Michael Dick <
> michael.d.dick@gmail.com
> > >wrote:
> > >
> > >>
> > >> That's embarrassing - it's right in the subject..
> > >>
> > >> By any chance are you using RuntimeUnenhancedClasses (if you're
> running
> > >> the
> > >> PCEnhancer then you're not and it _should_ all work). If you are then
> > >> trying
> > >> runtime enhancement might help.
> > >>
> > >> Sorry for missing the subject earlier.
> > >>
> > >> -mike
> > >>
> > >>
> > >> Christopher Gardner wrote:
> > >> >
> > >> > 1.2.1
> > >> >
> > >> > On Fri, Aug 21, 2009 at 5:24 PM, Michael Dick
> > >> > <mi...@gmail.com>wrote:
> > >> >
> > >> >>
> > >> >> Which version of OpenJPA are you using?
> > >> >>
> > >> >> This sounds like  http://issues.apache.org/jira/browse/OPENJPA-843
> > >> >> OPENJPA-843 .
> > >> >>
> > >> >> -mike
> > >> >>
> > >> >>
> > >> >> Christopher Gardner wrote:
> > >> >> >
> > >> >> > No matter what value I set cascade to, the update statement
> > prevails.
> > >> >> > Here
> > >> >> > is the last setting.  I've tried every value.
> > >> >> > class A {
> > >> >> > @ManyToOne(optional = false, cascade = CascadeType.REMOVE)
> > >> >> > @JoinColumn(name
> > >> >> > = "b_id")
> > >> >> >     private B b;
> > >> >> > }
> > >> >> >
> > >> >> > On Fri, Aug 21, 2009 at 4:54 PM, Christopher Gardner <
> > >> >> > chris.r.gardner@gmail.com> wrote:
> > >> >> >
> > >> >> >> What value of the cascade type do you set?
> > >> >> >>
> > >> >> >>
> > >> >> >> On Fri, Aug 21, 2009 at 4:42 PM, C N Davies <cn...@cndavies.com>
> > >> wrote:
> > >> >> >>
> > >> >> >>> I just set cascade type on the field that I don't update but
> want
> > >> the
> > >> >> >>> join
> > >> >> >>> to be persisted.
> > >> >> >>>
> > >> >> >>> -----Original Message-----
> > >> >> >>> From: Christopher Gardner [mailto:chris.r.gardner@gmail.com]
> > >> >> >>> Sent: Saturday, 22 August 2009 3:25 AM
> > >> >> >>> To: users@openjpa.apache.org
> > >> >> >>> Subject: Superfluous Updates for a @ManyToOne in OpenJPA 1.2.1
> > >> >> >>>
> > >> >> >>> Class A has a unidirectional many-to-one relationship with
> Class
> > B.
> > >> >> I
> > >> >> >>> change a property on a Class A object and persist the object.
> >  The
> > >> >> log
> > >> >> >>> shows
> > >> >> >>> SQL update statements called for both A and B.  I have no
> cascade
> > >> >> >>> options
> > >> >> >>> set on A's @ManyToOne.  I do not want any updates to B because
> > it's
> > >> >> not
> > >> >> >>> logical to do so and it's inefficient. B represents standard,
> > >> >> >>> boilerplate
> > >> >> >>> data for many A's.  Also, it adds no value for B to know about
> A.
> > >>  No
> > >> >> >>> update
> > >> >> >>> is appropriate in this context.  How do I stop updates to B?
> > >> >> >>>
> > >> >> >>>
> > >> >> >>
> > >> >> >
> > >> >> >
> > >> >>
> > >> >> --
> > >> >> View this message in context:
> > >> >>
> > >>
> >
> http://n2.nabble.com/Superfluous-Updates-for-a-ManyToOne-in-OpenJPA-1-2-1-tp3492419p3492691.html
> > >> >> Sent from the OpenJPA Users mailing list archive at Nabble.com.
> > >> >>
> > >> >
> > >> >
> > >>
> > >> --
> > >> View this message in context:
> > >>
> >
> http://n2.nabble.com/Superfluous-Updates-for-a-ManyToOne-in-OpenJPA-1-2-1-tp3492419p3492745.html
> > >> Sent from the OpenJPA Users mailing list archive at Nabble.com.
> > >>
> > >
> > >
> >
>