views:

75

answers:

0

I am using Fluent NHibernate Automapping and am pretty new to this framework. I have a 'Tab' object which has a single reference to another object 'Caption'.

When using Automapping, this relation is generated in the hbm file as a many-to-one relationship with cascade="all" as I have used the Cascade.All() setting for this.

Because of this, I am able to persist the Caption object directly when I persist the Tab object. But, when I delete the Tab object, the caption object does not get deleted automatically, and it gives me FK reference errors.

I guess I have to use the Cascade.Delete() setting to make this happen. But, If I do that I will loose the functionality of saving the Caption object on persisting the Tab object.

Is there a way to get these both? i.e. Save the Caption object when persisting the Tab object, and deleting the Caption object when Tab is deleted using Automapping?

related questions