I have issue with cascade a one to many relationship. One of my table contains a component, and the component is linked to another table which is my gallery (gallery have many kind of relationship with other tables.). Then the component is used in one of my base class. I used entity developer to generate the code, and it done it with these lines : Baseinfo.hbm.xml
...
<component>
...
<many-to-one name="LocationMap" class="..." cascade="all">
<column name="ImageId" not-null="true"/>
</many-to-one>
</component>
....
Since I needed to set it some times to null, I change not-null to "false". Everything worked fine till I come across deleting a record. After setting LocationMap to null, I check database and I saw the image record still exist. After some foruming I did also add "delete-orphan" to cascade options, man: cascade="all,delete-orphan" but it didn't work, I also put application on debug mode, and after performing save code, I tried this on immediate windows: session.Flush(); and that didn't worked to... I don't wanna go through ugly coding, and Remember to delete a record on later code, cause it don't work... , what should I do?!
I don't think
all,delete-orphan
supported withmany-to-one
andcomponent
. See this question, with a possible work around.