views:

187

answers:

0

This strikes me as an odd problem.

I have two classes representing tables in my database. The first simply has an int ID field and a varchar NAME field; it's *.hbm.xml mapping file contains the following (everything works as expected with this model):

  <class name="CBaseDataProvider.Models.PC, CBaseDataProvider" table="pc">
    <id name="Id" column="Id" type="int">
      <generator class="identity" />
    </id>

    <property name="PCName" column="PCName" type="string" />

    <bag name="Members">
      <key column="PCId"/>
      <one-to-many class="CBaseDataProvider.Models.Member, CBaseDataProvider" />
    </bag>
  </class>
</hibernate-mapping>

The second has a int ID field, and a bunch of random informational string, datetime, and int fields, as well as an int PCId field. When I do not have any associations mapped in the hbm.xml file for this class, I can create, edit, update, persist, etc... everything for both classes with no problems.

Now, when I add the following line to the xml map for the second class, with NO OTHER CHANGES, I get a mysql.data 'Parameter index out of bounds exception' when I try and save a new instance of the second class. For instances of the seconds class already persisted prior to the change, the additional mapped association works correctly:

<many-to-one name="PC" class="CBaseDataProvider.Models.PC, CBaseDataProvider" column="PCId"/>

What is causing this problem? I have tried populating the PC property in the seconds class prior to saving it in addition to the PCId field, but I still get the same error. That shouldnt matter anyway since the PC property of the seconds class is not a mapped column.