I have an object model like that:
Folder
- simple structure with name etc.File
- complex object containing reference toFolder
in which it is contained.
Folder doesn't know its Files and I don't want it to know. The relation is many-to-one and should be known on File's side only.
Anyway, I would like to rely on my database's ON DELETE CASCADE feature, so that when I remove Folder, I want all Files within that Folder to be deleted automatically. I can't use NHibernate's cascading as there is no relation from Folder to File.
I know that there is on-delete="cascade"
option for <key>
element in case of one-to-many relationship, but I can't find its equivalent for my model - when the relation is defined on many side.
Am I doing something wrong or do I really need to go through and delete all the Files within deleted Folder manually?