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 2010/05/03 21:01:10 UTC

Re: Forcing an Object to be always inserted/updated first during persist/merge

Hi Michael,

          Thanks for your reply. I already have that configuration in place,
but the problem is that, since I am using the @ElementDependent for orphan
deletion, to honor the SQL order while delete, the OpenJPA is updating the
child table foreignkey values to null, since my DB does not allow nulls in
to foreignkey columns, i get an error. 

So, I was wondering if there is a way that I can force a particular object
to be inserted/updated first before all the other objects in the Tree.
Since, the object that is at the top most level needs to be inserted first
because of some requirement that we have.

Thanks,
JP
-- 
View this message in context: http://openjpa.208410.n2.nabble.com/Forcing-an-Object-to-be-always-inserted-updated-first-during-persist-merge-tp4990960p4999545.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Forcing an Object to be always inserted/updated first during persist/merge

Posted by Ян Программист <we...@gmail.com>.
Interesting idea is to use a message broker to create complex
commit/rollback rules between UpdateManager instances on separated machines
(runtimes) for dealing with managed Java applications. John

2010/5/3 JayaPrakash <jp...@sify.com>

>
> Hi Michael,
>
>          Thanks for your reply. I already have that configuration in place,
> but the problem is that, since I am using the @ElementDependent for orphan
> deletion, to honor the SQL order while delete, the OpenJPA is updating the
> child table foreignkey values to null, since my DB does not allow nulls in
> to foreignkey columns, i get an error.
>
> So, I was wondering if there is a way that I can force a particular object
> to be inserted/updated first before all the other objects in the Tree.
> Since, the object that is at the top most level needs to be inserted first
> because of some requirement that we have.
>
> Thanks,
> JP
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Forcing-an-Object-to-be-always-inserted-updated-first-during-persist-merge-tp4990960p4999545.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

Re: Forcing an Object to be always inserted/updated first during persist/merge

Posted by Pinaki Poddar <pp...@apache.org>.
Hi,
  Did you try orphan deleting from the leaf?

  Say A has many B and B has many C and C has many D

  Then some thing like this in A.java

   @OneToMany(...., orphanDelete=true)
   List bs;
   void deleteChildren() {
      for (B b : bs) b.deleteChildren();
      bs = null;
   }

   And in B.java

   @OneToMany(...., orphanDelete=true)
   List<C> cs;
   void deleteChildren() {
      for (C c : cs) c.deleteChildren();
      cs = null;
   }


And then at the application level,

   A a = ...;
  a.deleteChildren();

   

-----
Pinaki 
-- 
View this message in context: http://openjpa.208410.n2.nabble.com/Forcing-an-Object-to-be-always-inserted-updated-first-during-persist-merge-tp4990960p5006108.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.