I actually think this issue is more concerned with how we're managing collections than inheritance, I just realised the search.Filters collection is being directly replaced rather than the persistent collection cleared and/or manipulated and also the child collections aren't mapped as inverse.
On Aug 23, 8:11 pm, DannyT <[email protected]> wrote: > First my scenario: > > we have an abstract Filter class > > Filter > +Id > +Search > > and two implementations of said class: > > CategoryFilter : Filter > +Category > > ManufacturerFilter : Filter > +Manufacturer > > And finally the Search class which has a collection of filters: > > Search > +<Filter>IList filters > > Originally we had a "table per subclass", however, when saving a filter NH > would delete all filters from the Search object (as expected) and so delete > from the table representing the abstract entity but would not delete the > orphaned rows (in the subclass tables) because they technically still had > 1:1 associations to categories and manufacturers. > > So we're now trying this with table per concrete class where we would not > end up with orphaned rows but I think we're missing something as NH is still > looking for the abstract table. When the collection is updated, NH tries to > update the entities from the abstract table's reference to Search to null > but the table doesn't exist and obviously errors. > > Mapping is now: > > <class name="Filter" > abstract="true"> > <id name="Id" column="Filter_Id"> > <generator class="hilo"/> > </id> > > <many-to-one name="Search" > column="Search_Id" /> > > <union-subclass > table="CategoryFilters" > name="CategoryFilter"> > > <many-to-one name="Category" > column="Category_Id"></many-to-one> > </union-subclass> > > <union-subclass > table="ManufacturerFilters" > name="ManufacturerFilter"> > > <many-to-one name="Manufacturer" > column="Manufacturer_Id"></many-to-one> > </union-subclass> > </class> > > When saving the search object, NH first tries to update the Filter table > (which doesn't exist) and set the Search_Id to null, should it not be > performing that action on the concrete classes table? > > Hopefully that makes sense and someone can point me in the right direction? > > Many Thanks, > > Dan > > -- > geek -http://danny-t.co.uk > mtb -http://dannyt.posterous.com > > *** please sponsor me:http://justgiving.com/dannytmtb*** -- 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.
