Hi Emmanuel,
I also have a problem with manytomany query. Following are my codes:
public class Account {
| ...
| @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE},
| fetch = FetchType.LAZY, mappedBy="accounts")
| public List<Group> getGroups() {
| return groups;
| }
|
| public void setGroups(List<Group> groups) {
| this.groups = groups;
| }
| ...
| }
|
| pulic class Group {
| ...
| @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch =
FetchType.EAGER)
| @JoinTable(table = @Table(name = "account_groups"),
| joinColumns = [EMAIL PROTECTED](name =
"ACCOUNT_ID")},
| inverseJoinColumns = [EMAIL PROTECTED](name =
"GROUP_ID")})
| public List<Account> getAccounts() {
| return accounts;
| }
|
| public void setAccounts(List<Account> accounts) {
| this.accounts = accounts;
| }
| ...
| }
|
|
| EntityManager em;
|
| public Account getAccount(String userName) {
| return (Account) em.createQuery("select a from Account a left outer
join a.groups where a.userName = :userName")
| .setParameter ("userName", userName)
| .getSingleResult();
| }
|
when I run it, I always got the exceptions:
java.lang.RuntimeException: org.jboss.tm.JBossRollbackException: Unable to
commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=Laptop/58,
BranchQual=, localId=58] status=STATUS_NO_TRANSACTION; - nested throwable:
(org.hibernate.HibernateException: Found shared references to a collection:
com.gdocs.model.Account.groups)
|
I could not figure out what is wrong. Thank you very much for any advice in
advance. Any helps are appreciated.
GUS
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3925513#3925513
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3925513
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user