Hibernate - One to many relation - foreign key always “null”

后端 未结 2 1771
温柔的废话
温柔的废话 2020-12-10 19:37

I have two really simple objects and one object should contain the other one in an \"one-to-many\" relation in a set. The objects get inserted correctly in the database, but

2条回答
  •  醉酒成梦
    2020-12-10 20:03

    It's quite simple: you never initialize the testObj field in Children (which should be named Child, BTW). Children.testObj is the owner of the association, and is the field that is mapped to the join column, so if it's null, the join column will be null.

提交回复
热议问题