Hey there. I have been trying to figure out how to configure the mapping with both NH and FluentNH for days, and I think I'm almost there, but not quite. I have the following problem.
What I need to do is basically map these two entities, which are simplified versions of the actual ones.
Airlines
varchar2(3) airlineCode //PK
varchar2(50)
Aircraft
varchar2(3) aircraftCode //composite PK
varchar2(3) airlineCode //composite PK, FK referencing PK in Airlines
varchar2(50) aircraftName
My classes look like
class Airline
{
string AirlineCode;
string AirlineName;
IList<Aircraft> Fleet;
}
class Aircraft
{
Airline Airline;
string AircraftCode;
string AircraftName;
}
Using FluentNH, I mapped it like so
AirlineMap
Table("Airlines");
Id(x => x.AirlineCode);
Map(x => x.AirlineName);
HasMany<Aircraft>(x => x.Fleet)
.KeyColumn("Airline");
AircraftMap
Table("Aircraft");
CompositeId()
.KeyProperty(x => x.AircraftCode)
.KeyReference(x => x.Airline);
Map(x => x.AircraftName);
References(x => x.Airline)
.Column("Airline");
Using Nunit, I'm testing the addition of another aircraft, but upon calling transaction.Commit after session.Save(aircraft), I get an exception: "System.IndexOutOfRangeException : Invalid index 22 for this OracleParameterCollection with Count=22." The Aircraft class (and the table) has 22 properties.
Anyone have any ideas?