I have an object with these properties:
private Long idMenu;
private String otherProperties;
.
.
private Set roles = new LinkedHashSet();
And this mapping:
<hibernate-mapping default-lazy="false">
<class name="portalbcn.Menu" table="menu">
<id name="idMenu" column="idMenu">
<generator class="native"/>
</id>
.
.
<set name="roles" table="menu_role">
<key column="idMenu" />
<many-to-many class="portalbcn.Role" column="idRole" />
</set>
</class>
</hibernate-mapping>
In my application I have a form in which I modifiy the properties of the menu object and then save it to the database,
but I have no information about its roles in this form.
The problem is that the roles set of the menu object is null when I save the menu object, so all its dependent registers in
menu_role table are removed from the database.
Is the a way to avoid this?, I only need the roles set to retrieve information, not to update it.
Thank you,
Óscar.
|