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
-~----------~----~----~----~------~----~------~--~---

Reply via email to