I have a class that I've mapped that contains a composite-id. It's a simple class with three fields, two of which are foreign keys to other objects:
Code:
<class name="QtrReading" table="qtrreading" lazy="true">
<composite-id>
<key-property name="Qtr" column="qtr_id"/>
<key-property name="Sensor" column="sensor_id"/>
</composite-id>
<property name="Amount" type="double">
<column name="amount" sql-type="number" not-null="false" />
</property>
<many-to-one name="Qtr"
column="qtr_id" class="Qtr" not-null="true" not-found="exception"/>
<many-to-one name="Sensor"
column="sensor_id" class="Sensor" not-null="true" not-found="exception"/>
<class>
but I can't seem to save this. When I create an object and save it, I'm getting the following error:
Quote:
System.IndexOutOfRangeException: Invalid index 3 for this OracleParameterCollection with Count=3.
When I enable Debug, I can see that NHibernate is trying to set more than the three fields in the insert statement:
Code:
DEBUG NHibernate.AdoNet.AbstractBatcher - Building an IDbCommand object for the SqlString: INSERT INTO developer.qtrreading (amount, qtr_id, sensor_id) VALUES (?, ?, ?)
DEBUG NHibernate.Persister.Entity.AbstractEntityPersister - Dehydrating entity: [zedi.access.domain.entities.QtrReading#zedi.access.domain.entities.QtrReading]
DEBUG NHibernate.Type.DoubleType - binding '1.23' to parameter: 0
DEBUG NHibernate.Type.Int32Type - binding '481164597' to parameter: 1
DEBUG NHibernate.Type.Int32Type - binding '891287' to parameter: 2
DEBUG NHibernate.Type.Int32Type - binding '481164597' to parameter: 3
DEBUG NHibernate.AdoNet.AbstractBatcher - Closed IDbCommand, open IDbCommands: 0
DEBUG NHibernate.AdoNet.ConnectionManager - registering flush end
Can anyone tell me what's happening here? Is my mapping incorrect?
Thanks,
Dave.