noreservations wrote:
<class name="test.dataobjects.EmailUser" table="edelivery_user">
<id name="index" column="id_index">
<generator class="increment" />
</id>
<property name="userId" column="user_id" />
<set name="emailAddrs">
<key column="user_id" />
<element column="email_addr" type="string" not-null="true" />
</set>
</class>
Hibernate: insert into user_email (user_id, id_index) values (?, ?)
could not bind value 'TESTSETUSER' to parameter: 1; Invalid argument: parameter index 1 is out of range.
I don't see user_email defined anywhere in your mapping file so it is hard to understand what that sql is. However, the element thing should work if you specify the table on the set tag, and you set a property-ref in the key tag since the primary key is not userId.
Code:
<set name="emailAddrs" table="user_email">
<key column="user_id" property-ref="userId" />
<element column="email_addr" type="string" not-null="true" />
Hibernate documentation has a quite similar example. You may want to check out section 1.3.4 Collection of values.
Farzad-