openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "C N Davies" <>
Subject RE: Merge updating the wrong table
Date Tue, 21 Jul 2009 09:12:32 GMT
I finally worked it out. Took me a few days but I have to set cascade type
on the Role entity to "Refresh" then it will only update the join table and
not attempt to update the entity tables. 






From: C N Davies [] 
Sent: Sunday, 19 July 2009 5:14 AM
To: ''
Subject: Merge updating the wrong table


I have a parent entity and a child entity.  It uses a join table to hold the
relationship. When I do a get on the parent it retrieves the children
correctly but when I call merge on the parent after adding some children, it
tries to persist the children in the child table not into the join table. A
is a basic outline of my code is below.  I don't understand why the get is
working but the mere is working this way. Am I missing something obvious?






public class Role extends CoreObject{


      private List <Permission> permissions;



       * @param permissions the permissions to set


      public void setPermissions(List <Permission> permissions) {

            this.permissions = permissions;




       * @return the permissions


      public List <Permission> getPermissions() {

            return permissions;








public class Permission extends CoreObject{





I call merge like so :


public void merge(CoreObject co){

            EntityManagerFactory emf =

            threadLocal = new ThreadLocal<EntityManager>();

            em = threadLocal.get();

            em = emf.createEntityManager();









  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message