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 Mon, 20 Jul 2009 04:58:19 GMT
I've been thinking about this a bit more and it seems I should have a
@ManyToMany join since a single role can have many permissions and any
single permission can be joined to many roles. 


My role table has all my roles, my permission table has all my permissions.
All I need the merge/persist of the role entity to do is update the join
table. What annotation should I use for this? 


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