I have a fully working many-to-many mapping using a bag, and have been using this mapping for quite some time. I tried switching the bag to a set, both in code and the mapping file, and all of a sudden I receive this mapping error:
Code:
[MappingException: Foreign key in table DocumentMap must have same number of columns as referenced primary key in table BuildOrders]
NHibernate.Mapping.ForeignKey.set_ReferencedTable(Table value) +306
NHibernate.Cfg.Configuration.SecondPassCompileForeignKeys(Table table, ISet done) +347
NHibernate.Cfg.Configuration.SecondPassCompile() +906
NHibernate.Cfg.Configuration.BuildSessionFactory() +12
SpringAir.Global.StartHibernate() in C:\Documents and Settings\sv\My Documents\Visual Studio Projects\SpecAndQuote\Global.asax.cs:187
SpringAir.Global.Application_Start(Object sender, EventArgs e) in C:\Documents and Settings\sv\My Documents\Visual Studio Projects\SpecAndQuote\Global.asax.cs:175
Only the BuildOrder takes part in the many-to-many relationship between FreightOrder and Project:
Code:
Project <-(1)--(n)-> BuildOrder <-(m)--(1)-> FreightOrder
| |
+-(n)--------(via BuildOrder)--------(m)-+
The 1,n,m indicate the arity of the relationship, so Project:FreightOrder is n:m (the many-to-many I'm trying to map), Project:BuildOrder is 1:n (one-to-many), etc.
I'm not sure how the DocumentMap object is getting involved; BuildOrder has a one-to-many relationship via a dictionary with DocumentMap, but it has nothing to do with the above that I can see.
Hibernate version: 1.0.4
Mapping documents:Code:
<bag name="freightOrders" lazy="true" table="BuildOrders" order-by="FreightOrderId" cascade="none">
<key column="ProjectId" />
<many-to-many class="SpringAir.Objects.FreightOrder, SpringAir.Objects" column="FreightOrderId" />
</bag>
Change "bag" to "set" above, and it triggers the error. Any ideas what this might mean?