[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5691?page=c...
]
Suyash Kaulgud commented on HHH-5691:
-------------------------------------
I was able to resolve the issue by removing references of other entity from toString()
method. i.e removed references of BankAccount from User object's toString method and
vice versa. However, i thought that hibernate was able to detect such a cyclic dependency
and not throw stackoverflow exception.
JPA with Hibernate 3 - ManyToMany-Stack overflow and Multiple bag
errors
------------------------------------------------------------------------
Key: HHH-5691
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5691
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.1
Environment: Spring 3.0.3
Hibernate-core : 3.5.1-Final
Hibernate-annotations : 3.5.1-Final
hibernate-common-annotations : 3.2.0-Final
hibernate-entitymanager : 3.5.1-Final
Mysql database
Junit 4
Reporter: Suyash Kaulgud
Attachments: fms-web.zip
I am facing issues while retrieving data for entities having bi-directional many-to-many
relationship. If I use List for storing entities, I get unable to fetch multiple bags
simultaneously error. If i change my code to use Set, I get stackoverflow error.
Details :
Spring 3.0.3
Hibernate-core : 3.5.1-Final
Hibernate-annotations : 3.5.1-Final
hibernate-common-annotations : 3.2.0-Final
hibernate-entitymanager : 3.5.1-Final
Mysql database
Junit 4
User has Many Bank Accounts; Bank Account can have many users
User.java
@ManyToMany(fetch = FetchType.EAGER, mappedBy="user")
private List<BankAccount> bankAccounts = new ArrayList<BankAccount>();
BankAccount.java
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "user_bankaccount",
joinColumns = @JoinColumn(name="bank_account_id"),
inverseJoinColumns = @JoinColumn(name = "user_id")
)
private List<User> user = new ArrayList<User>();
DB Tables
Users
user_id PK
Bankaccount
bank_account_id PK
user_bankaccount
bank_account_id PK ( references bankaccount.bank_account_id )
user_id PK ( references user.user_id )
issues
when I try to get all the users data (getAllUsers) using a JUnit test case, I get unable
to fetch multiple bags simultaneously error.
If I use Set and HashSet instead of List and ArrayList respectively, I get stackoverflow
error.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira