Hi, I am having the following problem domain classes:
Account, Group and Share (all entities)
The relationship between Account and Group is one-to-many
and between Group and Share is also one-to-many.
How can I, in a single session, add a Group to an existing Account and with a new Share associated to the Group?
If I do:
Code:
account = (Account) session.load(Account.class, new Long(id));
Group group = new Group();
group.set...
group.set...
Share share = new Share();
share.set...
share.set...
group.getShares().add(share);
share.setGroup(group);
account.getGroups().add(group);
group.setAccount(account);
session.flush();
This hangs after adding the share to the group's collection.
These one-to-many relationships are mapped with a Set (HashSet) and a cascade of "save-update".
If I do not add a share, the code works.
Any suggestion?
cheers