I have two classes having parent and child relationship
<class name="parent">
<id name="id">
<generator class="assgned"/>
</id>
<property name="currency"/>
<property name="description" length="400">
</class>
<class name="child">
<id name="id">
<generator class="native"/>
</id>
<property name="someprop1"/>
<property name="someprop2">
<many-to-one class="Parent" column="parent_field" name="parent" cascade="save-
update" />
</class>
when I insert a new row in child, it updates the existing row in child class instead of inserting a new row and mapping the new id with foreign key.
I think I am mistaken in choice of generator class and cascade option. Please help.
级联的映射应在父类中,并指向子类。.如果在父列表中添加新的子对象以及较旧的对象,则在保存父对象时..它将以自动递增的方式保存在新行中id(如果已配置),请记住,如果要将子代与父代一起保存,并且所有子代都在对象中设置了主键,它们将更新数据库中的现有行,因为这是正确的工作行为。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.