Hi
I have a simple question: what's the best way to delete a child record?
I'm doing it like this at the moment (pseudocode):
A contains B
therefore I have: a.getB();
How to delete:
B b = a.getB( )
a.setB(null)
save( a )
delete( b )
This gets around FK constraints. But, I would like to do this:
Code:
getHibernateTemplate().delete(a.getB());
I've played around with the mapping and the 'cascade' option but haven't stumbled upon one that works for my case.
Code:
<many-to-one name="note" class="com.lsb.uk.mqs.value.ChecklistItemNoteValue" column="NOTE_ID" foreign-key="NOTE_ID" unique="true"/>
Thanks