users
Code:
<class name="Users" table="Users">
<id name="userid" type="string">
<column name="userid" />
<generator class="uuid.hex"/>
</id>
<property name="password" column="password" type="string"/>
<property name="enabled" column="enabled" type="boolean"/>
<property name="userNick" column="userNick" type="string"/>
<set name="menus" inverse="true" lazy="true" cascade="all">
<key column="userid"/>
<one-to-many class="Menu"/>
</set>
<property name="userName" column="userName" type="string"/>
</class>
menu:
Code:
<class name="Menu" table="Menu">
<id name="menuid" type="string">
<column name="menuid" />
<generator class="uuid.hex"/>
</id>
<property name="menuName" column="menuName" type="string"/>
<many-to-one name="user" class="Users" column="userid" not-null="true"/>
<property name="link" column="link" type="string"/>
<property name="description" column="description" type="string"/>
<set name="childmenus" lazy="true" cascade="all" inverse="true">
<key column="fid"/>
<one-to-many class="Menu"/>
</set>
</class>
it work success between users and menu.
but how to do with the menu and its childmenus;
menu.java
Code:
public class Menu {
private Set childmenus;
private String description;
private String link;
private String menuid;// the Hibernate identifier
private String menuName;
private Users user;
..........................
//other is common setter and getter
}
when i add a children menu to a menu.
Code:
child=new Menu();
child.setMenuName("childtest");
child.setDescription(" a child menu for file0");
child.setUser(users);
Set childmenus=new HashSet();
childmenus.add(child);
menu.setChildmenus(childmenus);
but the new record in the database has not a fid .
pls tell me why?