Beginner |
|
Joined: Wed Mar 17, 2004 12:44 am Posts: 25
|
Hello folks,
In a parent child relationship
Parent
====
Parent_Id
Child
===
Child_Id
Parent_Id
Another_Id
In the parent hbm I define a <set> of child objects and in child hbm I have a <many-to-one> relationship with parent and not-null = "true".
Now I get the set from the parent domain object that contains objects of the child class. I do some addition and deletion to the set that reflects the database due to cascade="all-delete-orphan".
Problem : While adding the Set that has unique objects to the database table hibernate should fire delete on some of the records that no longer exists in the set. But it is firing an insert first. And in this insert statement it is trying to insert Parent_Id as null. However I have already called setParent(parentObject) method that sets the parent object for me. The Parent_Id has a not null constraint and a Unique constraint jointly with Another_Id.
Can anyone throw some light on this ? M not sure how should I proceed further..
nitin
|
|