I'm just curious if there is a mapping work around to problem described below.
Given the following schema:
Table: List
PK - ListName
...
Table: Attribute
PK - AttributeName
...
Table: ListAtt
PK, FK1 - ListName
PK, FK2 - AttributeName
And the following mapping:
Code:
<class name="AppList, ApplicationLists.ORM" table="List">
...
<map name="Attributes" table="ListAtt" >
<key column="ListName"/>
<index column="AttributeName" type="String"/>
<many-to-many column="AttributeName" column="AttributeName" class="Attribute, ApplicationLists.ORM"/>
</map>
...
</class>
I run into the following exception:
failed: System.Xml.XmlException : 'column' is a duplicate attribute name. I have also tried the following mapping for the same AppList class mapping:
Code:
<map name="Attributes" table="ListAtt">
<key column="ListName"/>
<index-many-to-many column="AttributeName" class="Attribute, ApplicationLists.ORM"/>
</map>
With it I run into the following exception:
failed: NHibernate.MappingException : The element 'urn:nhibernate-mapping-2.0:map' has incomplete content. Expected 'urn:nhibernate-mapping-2.0:element urn:nhibernate-mapping-2.0:one-to-many urn:nhibernate-mapping-2.0:many-to-many urn:nhibernate-mapping-2.0:composite-element urn:nhibernate-mapping-2.0:many-to-any'.
I know the solution may be to add an index column to the ListAtt table, but it seems like this is a very common implementation without having to do so. I would think that there should be, or potentially is, a way to implement an IDictionary collection with the <map> element using the foreign key as both the relationship mapping and the index mapping. In my case implementing an index column would introduce redundant data in the table. Please advise. Thanks in advance for any help.
nathan