-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Many To Many Assocations not being save
PostPosted: Fri Jul 16, 2010 12:51 pm 
Newbie

Joined: Wed Apr 14, 2010 4:33 pm
Posts: 8
Hi all,
I was having problems getting my @ManyToMany association collections to save their associations inside of the join table. I was wondering if anyone had seen this problem before? I have seen that you can use the @Persister and make a customer persister but I wanted to see if there was a way I could save the associations of user and groups inside of my association table without having to make a custom persister.

Database
Code:
tblUser
userID

tblGroup
groupID

tblUserHasGroup
userID
groupID


User
Code:
@ManyToMany(cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH},targetEntity=Group.class)
   @JoinTable(
            name="tblUserHasGroup",
            joinColumns=@JoinColumn(name="userID", referencedColumnName="id"),
            inverseJoinColumns=@JoinColumn(name="groupID", referencedColumnName="id")
         )
   @Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.PERSIST})
   public Set<Permission> getGroups()   
          .........


Group
Code:
@ManyToMany(mappedBy = "groups", targetEntity=User.class, cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH})


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.