I have the following situation in a legacy database [sample]
table1
**ID_TABLE1 [PK]
ID_SOURCE** [PK]
table2
**ID_TABLE2 [PK]
ID_SOURCE** [PK]
table3
**ID_TABLE3 [PK]
ID_SOURCE** [PK][FK]
ID_TABLE2 [FK]
ID_TABLE1 [FK]
public partial classTable3Map : ClassMap<TABLE3>
{
public classTable3Map()
{
Table("TABLE3");
LazyLoad();
CompositeId().KeyProperty(x => x.ID_TABLE3 , "ID_TABLE3").KeyProperty(x => x.ID_SOURCE, "ID_SOURCE");
References(x => x.TABLE1).Columns("ID_TABLE1 ", "ID_SOURCE");
References(x => x.TABLE2).Columns("ID_TABLE2 ", "ID_SOURCE");
}
}
When i try to save this type of objects nhibernate throw a
**System.IndexOutOfRangeException**
Message=Index xx non valid for xxxParameterCollection
I'll see that it have more input then parameter (the duplicates ID_SOURCE columns)
When i try to map a n to m relation is the same situation.
I can save if i map the id instead of objects (reference) and save childrens before insert but i have to rewrite the model and doing many manual adjustement.