Hi ...

I implemented a logical delete by adding a DeleteEventListener in
NHibernate and setting an IsDeleted flag. I like this strategy because
all marked (ILogicallyDeletable) classess are being deleted in
cascade.

However ... fetching data poses a problem. I added a where clause to
all the class elements in my xml mapping file, also to all sets and
bags etc...

Except for the unidirectional many-to-many relations, these are
problematic.

ex.
I have this structure
Product - ProductsPerExport - ExportDefinition

When deleting a product, the record in ProductsPerExport still exists
(obviously), resulting in an objectnotfound when resolving the
products in the export (productsperexport points to deleted products).
The mapping for the many-to-many in ExportDefinition looks like:

<set  name="_Products" lazy="true" table="productsperexport"
cascade="save-update" access="field">
                       <key column="ExportDefinition_ID" />
                       <many-to-many class="Product"
column="Product_ID" />
</set>

I tried adding where="Product.IsDeleted = 0" to the set element
without success.

Is there an elegant solution to this problem?

I already thought about replacing all many-to-many associations by two
one-to-many associations but this would involve quite some work. Let's
say I have around 7 many-to-many relations like this.

Kind regards ...

Yoeri

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to