I'm not sure whether the lack of responses means that my question isn't entirely clear on what I'm asking or that my use-case is so abnormal that no one has any suggestions or thoughts on how to proceed. For now, we've effectively removed the constraint in the database to avoid the errors and allow for NHibernate to manage the list index for us, but we're still very interested in potential solutions that would allow us to have our constraint in place to prevent the data from becoming inconsistent and yet still use NHibernate to manage our collection indexes. If there's any clarifications I can provide on the issue we're having, please let me know.
Thanks! Regards, Michael On Wed, Nov 11, 2009 at 10:46 AM, Michael Smith <[email protected]>wrote: > Consider an entity, Entry, that contains a collection of another > entity (many-to-many), Category, such that the Entry can be associated > with a given Category no more than once (implying a "set" and > constrained by the database) and the ordering of the Category entities > within the collection is fixed and is defined by an extra field on the > mapping table (implying a "list"). What would be the proper mapping > for such a case? > > Since a <set> doesn't use an <index>, and we can easily maintain > uniqueness of the Category entities in the application layer (as > opposed to using NHibernate for this), using <list> seems to make > sense since it will automatically handle the update of the ordering > value in the extra field on the mapping table (which the biggest > "feature" I'd like to use). Unfortunately, when updating the > collection, we encounter constraint violations due to the manner in > which NHibernate performs the updates (even when the new collection > values wouldn't ultimately cause a constraint violation) since we have > a unique constraint on the database between the related objects in the > mapping table. > > I've posted some sample tables and mappings along with a walk-through > of what SQL NHibernate is executing to cause the constraint violation > in a post on Stack Overflow: > > http://stackoverflow.com/questions/1711205/how-can-an-indexed-many-to-many-set-be-mapped-in-nhibernate > > Thanks for any assistance with this! > > Regards, > Michael > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
