I have two objects to persist; Account and Role. Account has a String username, a String password and a Set of Roles. Role has a String name, and a Set of Accounts. Hibernate creates a join table called accountroles to manage the Sets' many-to-many relationship. Everything works fine; Hibernate generates the correct SQL as far as I can tell. I inserted intermediate commits at each step just to make sure. On the last commit, I get a java.lang.StackOverflowError. I assume this has something to do with the bidirectional nature of the relationship. I must be getting an infinite loop of recursion or something. Any idea what I did wrong?
Hibernate version: version 3.0.2 , 27.04.2005
Mapping documents: Account.hbm.xml
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs: java.lang.StackOverflowError (that's it)
Name and version of the database you are using: hsqldb_1_7_3_3
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Joined: Nov 19, 2003
I almost forgot to mention, the above code uses the same instance of HashSet for userRole and adminRole.
The following code gave me the exact same result:
I also tried out this project with MySQL 3.0.16 and had the same problem.