You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by JayaPrakash <jp...@sify.com> on 2009/03/09 06:33:33 UTC

Update problem in OneToMany bidirection relationship

Hi,

   When using the OpenJPA OneToMany bidirection relationship, while
inserting a new record into the child table, the OpenJPA seems to update all
the other child rows which are identified by the same foreign key value id.

Lets say we have a SSN xxx-xx-xxxx of parent table and has four rows in the
child table which are referred by the same SSN. I am trying to insert a
fifth row in the child table for the same xxx-xx-xxxx. Now OpenJPA is
generating a 4 update statements on and one insert statement. I am not sure
why OpenJPA is behaving so strange, since I am explicitlly using
entityManager.persist() method  to save the child object. 

Here is relationship we have
Class Child

@OneToMany(Cascade=CascadeType.All, Fetch=FetchType.Eager)
@JoinColumns(name="id", columnDefinition="id")
private Parent parent;


Class Parent
@ManyToOne(mappedBy="parent")

I guess I might be missing some annotation to stop those updates. Could
anybody please suggest me as to how this can be avoided.

I kindly request you all to advice a workaround to avoid this, since this is
the only issue that is troubling us.

Thanks,

-- 
View this message in context: http://n2.nabble.com/Update-problem-in-OneToMany-bidirection-relationship-tp2447599p2447599.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

RE: Update problem in OneToMany bidirection relationship

Posted by C N Davies <cn...@cndavies.com>.
Use an ant build.xml I have mine attached, alter as required.

Chris



-----Original Message-----
From: kuldeep.poonia [mailto:kuldeep.poonia@delhiassam.com] 
Sent: Monday, 22 November 2010 6:53 PM
To: users@openjpa.apache.org
Subject: Re: Update problem in OneToMany bidirection relationship


Hi Pinki

I am  using @ManyToOne For the same. But Can u plz tell me how can I use
build-time enhancement.?
I already have been tries a lot for Build time but every time I failed.

--
View this message in context:
http://openjpa.208410.n2.nabble.com/Update-problem-in-OneToMany-bidirection-
relationship-tp2447599p5761874.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Update problem in OneToMany bidirection relationship

Posted by "kuldeep.poonia" <ku...@delhiassam.com>.
Hi Pinki

I am  using @ManyToOne For the same. But Can u plz tell me how can I use
build-time enhancement.?
I already have been tries a lot for Build time but every time I failed.

-- 
View this message in context: http://openjpa.208410.n2.nabble.com/Update-problem-in-OneToMany-bidirection-relationship-tp2447599p5761874.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Open Jpa 2.0 Release

Posted by Pinaki Poddar <pp...@apache.org>.
Hi,
  JPA 2.0 draft specification (dated around Oct 2008) had published a
'Criteria' API quite similar in spirit of what you are used to with
Hibernate. This API is available with OpenJPA 2.x and nightly built versions
and can be downloaded from OpenJPA website.
  During your migration exercise, you can try the Criteria API as it stands
in OpenJPA 2.0. It is a compliant implementation and will given you a feel
for this new API as well as OpenJPA the benefit of independent testing.
   The 'new' Criteria API is being finalized and will be available in new
draft of JPA 2.0 specification. OpenJPA implementation will follow shortly.  
 

Nitish Kumar wrote:
> 
> Hi all,
> 	I am planning to move to Open JPA from Hibernate for various
> reasons, including but not limited to dynamic fetch plan. One of the
> major issue which I am facing is lack of Criteria queries, as most of my
> project heavily use that feature. I am aware that it is a part of JPA
> 2.0 spec, and is in development. I wanted to know if there was any
> planned release date for Open Jpa 2.0, or is it possible to back port
> the criteria feature on 1.2.x release?
> 
> 
> Thanks and Regards,
> Nitish Kumar 
> 
> -------------------------------------------------------------------------------------------------------------------------
> "The information contained in this e-mail transmission is confidential and
> may be privileged. It is intended only for the 
> addressee(s) stated above. If you are not an addressee, any use,
> dissemination, distribution, publication, or copying of 
> the information contained in this e-mail is strictly prohibited. If you
> have received this e-mail in error, please 
> immediately notify us by telephone (+91 80 6618 6555), or e-mail the
> sender and delete the e-mail from your system. 
> If you do not want to receive our emails please let us know so that we may
> delete you from our email list. Proteans 
> Software Solutions and its parent group ("CAMO Group") do not accept
> liability for damage caused by this email, and may 
> monitor email traffic." 
> -------------------------------------------------------------------------------------------------------------------------
> 
> 
> 

-- 
View this message in context: http://n2.nabble.com/Update-problem-in-OneToMany-bidirection-relationship-tp2447599p2469568.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: Open Jpa 2.0 Release

Posted by Kevin Sutter <kw...@gmail.com>.
Nitish,
Just a heads up as well...  The Criteria API as currently defined by the
Public Draft Review of the JPA 2.0 spec (dated Oct 2008) is going under
major revisions.  The next Draft of the spec should be coming out within the
next few weeks.  Although our OpenJPA 2.0 nightlies contain an
implementation of the original Criteria API, it might be worth waiting for
the next revision of the spec before spending too many cycles on the old
Criteria API.

Kevin

On Thu, Mar 12, 2009 at 2:15 AM, Michael Dick <mi...@gmail.com>wrote:

> Hi Nitish,
>
> The goal is to release OpenJPA 2.0 fairly quickly after the spec finalizes.
> The most up to date information can be found on the 2.0 roadmap [1].
>
> Back porting the criteria feature to 1.2 would be a major and risky
> undertaking and we have no plans to do so at this time. We might consider
> doing something for 1.3.0 though.
>
> [1] http://cwiki.apache.org/confluence/display/openjpa/JPA+2.0+Roadmap
>
> -mike
>
> On Thu, Mar 12, 2009 at 12:51 AM, Nitish Kumar <Nitish.Kumar@proteans.com
> >wrote:
>
> > Hi all,
> >        I am planning to move to Open JPA from Hibernate for various
> > reasons, including but not limited to dynamic fetch plan. One of the
> > major issue which I am facing is lack of Criteria queries, as most of my
> > project heavily use that feature. I am aware that it is a part of JPA
> > 2.0 spec, and is in development. I wanted to know if there was any
> > planned release date for Open Jpa 2.0, or is it possible to back port
> > the criteria feature on 1.2.x release?
> >
> >
> > Thanks and Regards,
> > Nitish Kumar
> >
> >
> >
> -------------------------------------------------------------------------------------------------------------------------
> > "The information contained in this e-mail transmission is confidential
> and
> > may be privileged. It is intended only for the
> > addressee(s) stated above. If you are not an addressee, any use,
> > dissemination, distribution, publication, or copying of
> > the information contained in this e-mail is strictly prohibited. If you
> > have received this e-mail in error, please
> > immediately notify us by telephone (+91 80 6618 6555), or e-mail the
> sender
> > and delete the e-mail from your system.
> > If you do not want to receive our emails please let us know so that we
> may
> > delete you from our email list. Proteans
> > Software Solutions and its parent group ("CAMO Group") do not accept
> > liability for damage caused by this email, and may
> > monitor email traffic."
> >
> >
> -------------------------------------------------------------------------------------------------------------------------
> >
> >
>

Re: Open Jpa 2.0 Release

Posted by Michael Dick <mi...@gmail.com>.
Hi Nitish,

The goal is to release OpenJPA 2.0 fairly quickly after the spec finalizes.
The most up to date information can be found on the 2.0 roadmap [1].

Back porting the criteria feature to 1.2 would be a major and risky
undertaking and we have no plans to do so at this time. We might consider
doing something for 1.3.0 though.

[1] http://cwiki.apache.org/confluence/display/openjpa/JPA+2.0+Roadmap

-mike

On Thu, Mar 12, 2009 at 12:51 AM, Nitish Kumar <Ni...@proteans.com>wrote:

> Hi all,
>        I am planning to move to Open JPA from Hibernate for various
> reasons, including but not limited to dynamic fetch plan. One of the
> major issue which I am facing is lack of Criteria queries, as most of my
> project heavily use that feature. I am aware that it is a part of JPA
> 2.0 spec, and is in development. I wanted to know if there was any
> planned release date for Open Jpa 2.0, or is it possible to back port
> the criteria feature on 1.2.x release?
>
>
> Thanks and Regards,
> Nitish Kumar
>
>
> -------------------------------------------------------------------------------------------------------------------------
> "The information contained in this e-mail transmission is confidential and
> may be privileged. It is intended only for the
> addressee(s) stated above. If you are not an addressee, any use,
> dissemination, distribution, publication, or copying of
> the information contained in this e-mail is strictly prohibited. If you
> have received this e-mail in error, please
> immediately notify us by telephone (+91 80 6618 6555), or e-mail the sender
> and delete the e-mail from your system.
> If you do not want to receive our emails please let us know so that we may
> delete you from our email list. Proteans
> Software Solutions and its parent group ("CAMO Group") do not accept
> liability for damage caused by this email, and may
> monitor email traffic."
>
> -------------------------------------------------------------------------------------------------------------------------
>
>

Open Jpa 2.0 Release

Posted by Nitish Kumar <Ni...@proteans.com>.
Hi all,
	I am planning to move to Open JPA from Hibernate for various
reasons, including but not limited to dynamic fetch plan. One of the
major issue which I am facing is lack of Criteria queries, as most of my
project heavily use that feature. I am aware that it is a part of JPA
2.0 spec, and is in development. I wanted to know if there was any
planned release date for Open Jpa 2.0, or is it possible to back port
the criteria feature on 1.2.x release?


Thanks and Regards,
Nitish Kumar 

-------------------------------------------------------------------------------------------------------------------------
"The information contained in this e-mail transmission is confidential and may be privileged. It is intended only for the 
addressee(s) stated above. If you are not an addressee, any use, dissemination, distribution, publication, or copying of 
the information contained in this e-mail is strictly prohibited. If you have received this e-mail in error, please 
immediately notify us by telephone (+91 80 6618 6555), or e-mail the sender and delete the e-mail from your system. 
If you do not want to receive our emails please let us know so that we may delete you from our email list. Proteans 
Software Solutions and its parent group ("CAMO Group") do not accept liability for damage caused by this email, and may 
monitor email traffic." 
-------------------------------------------------------------------------------------------------------------------------


Re: Update problem in OneToMany bidirection relationship

Posted by Pinaki Poddar <pp...@apache.org>.
1. 
> Class Child
> @OneToMany(Cascade=CascadeType.All, Fetch=FetchType.Eager)
> @JoinColumns(name="id", columnDefinition="id")
> private Parent parent;


@OneToMany annotation defines a many-valued association. Should you be using
@ManyToOne instead?

2. The multiple updates can happen if you are using runtime enhancement.
Switch to build-time enhancement, and then if the problem persists, post the
domain classes for further investigation.  


JayaPrakash wrote:
> 
> Hi,
> 
>    When using the OpenJPA OneToMany bidirection relationship, while
> inserting a new record into the child table, the OpenJPA seems to update
> all the other child rows which are identified by the same foreign key
> value id.
> 
> Lets say we have a SSN xxx-xx-xxxx of parent table and has four rows in
> the child table which are referred by the same SSN. I am trying to insert
> a fifth row in the child table for the same xxx-xx-xxxx. Now OpenJPA is
> generating a 4 update statements on and one insert statement. I am not
> sure why OpenJPA is behaving so strange, since I am explicitlly using
> entityManager.persist() method  to save the child object. 
> 
> Here is relationship we have
> Class Child
> 
> @OneToMany(Cascade=CascadeType.All, Fetch=FetchType.Eager)
> @JoinColumns(name="id", columnDefinition="id")
> private Parent parent;
> 
> 
> Class Parent
> @ManyToOne(mappedBy="parent")
> 
> I guess I might be missing some annotation to stop those updates. Could
> anybody please suggest me as to how this can be avoided.
> 
> I kindly request you all to advice a workaround to avoid this, since this
> is the only issue that is troubling us.
> 
> Thanks,
> 
> 

-- 
View this message in context: http://n2.nabble.com/Update-problem-in-OneToMany-bidirection-relationship-tp2447599p2463652.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.