Hibernate exception while saving with cascade=“save-update”

前端 未结 3 1969
梦如初夏
梦如初夏 2021-01-25 05:04

Here is my hbm and test code respectively. I am using Spring\'s HibernateTemplate. I doesn\'t use DAO. Hibernate 2.2.5 with Spring 2.0.7

hbm

<         


        
3条回答
  •  醉梦人生
    2021-01-25 05:08

    since instances of the same class are both parents and children, you need an id, which you have, but you also need a parent-id type column in the db (and field on the class) so the children can have a reference to their parent.

    See https://forum.hibernate.org/viewtopic.php?f=1&t=1004163

提交回复
热议问题