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