02 December 2005 - java_dev (original) (raw)
Hi colleagues! Could you please help?
Intro. DB schema contains object A which related with object B like "one-to-many". It means that the copy of the object A may has many related copies of the object B. The object B keeps the Id of the related object A in the field with "NOT NULL" attribute.
Problem. Hibernate does following strange things when I'm trying to delete object A:
- Trys to set "NULL" into field of object B, which keeps an Id of the related object A (sic!);
- Deletes related objects B;
- Deletes object A.
So, the 1 point becomes breakpoint, because of MS SQL doesn't lets Hibernate set NULL to the field with "NOT NULL" attribute. I have checked my suggestions -- all 3 points works if I remove restriction "NOT NULL".
Question. Maybe someone knows how to solve this problem?
p.s. Excuse my English :o)
Update. The solve was found thanks to charles! The parameter inverse="true" must be added to the bag of the object A.