In Authority.hbm.xml I have this:
Code:
<many-to-one name="userAccount" column="username" class="UserAccount" not-null="true" property-ref="username" />
and in UserAccount.hbm.xml I have this:
Code:
<set name="authoritySet" inverse="true" cascade="all">
<key column="username" property-ref="username"/>
<one-to-many class="Authority"/>
</set>
In UserAccount.java I added this:
Code:
private java.util.Set authoritySet = new HashSet();
public void addAuthority(Authority authority) {
getAuthoritySet().add(authority);
}
and in the code where I use all this, I do this:
Code:
Authority authority = new Authority();
authority.setUserAccount(newUserAccount);
newUserAccount.addAuthority(authority);
Thanks you guys's help.