I'm receiving an error when trying to map a many-to-many relationship using an <idbag>
everything works fine when I add one item to the collection and save but when I add a second item to the collection nhibernate does the two inserts and then tries to update the first records id to a 'System.Object' which in turn is throwing the error
Failed to COMMIT NHibernate transaction ---> System.InvalidCastException: Failed to convert parameter value from a Object to a Int32. ---> System.InvalidCastException: Object must implement IConvertible.
my mapping is below
Code:
<idbag
name="mCollection"
table="collection_xref"
fetch="subselect"
inverse="false"
lazy="false"
access="field"
cascade="all-delete-orphan"
>
<collection-id column="id" type="int">
<generator class="native">
<param name="sequence">collection_xref_seq</param>
</generator>
</collection-id>
<key column="class_a_id"></key>
<many-to-many class="ClassB" column="class_b_id"></many-to-many>
</idbag>
any help would be appreciated