I have a java object, which holds a collection of people. When I insert these people into the database, I need to generate the key myself in my own code, since it is kind of complex and comes from a tabe with multiple columns that need to be looked at. For some reason, it wants to update the record, even though it is a brand new record that should be inserted instead. My object that holds the collection defines the collection like this:
Code:
<set name="witnesses" lazy="true"
cascade="none" where="PERSON_TYPE_CD='WI'">
<meta attribute="field-description">
@hibernate.set
lazy="true"
inverse="true"
cascade="none"
@hibernate.collection-key
column="RB_NUMBER"
@hibernate.collection-one-to-many
class="org.dotcomm.opd.valueobjects.Person"
</meta>
<key>
<column name="RB_NUMBER" />
</key>
<one-to-many class="org.dotcomm.opd.valueobjects.Person" />
</set>
My Id for the person is defined like this:
Code:
<id
name="incidentPersonId"
type="java.lang.Integer"
column="INCIDENT_PERSON_ID"
unsaved-value="undefined"
>
<meta attribute="field-description">
@hibernate.id
generator-class="assigned"
type="java.lang.Integer"
column="INCIDENT_PERSON_ID"
</meta>
<generator class="assigned" />
</id>
From everything I have read, this is the correct way to do it, and I have other "person" objects that are not Sets that are inserting fine, but when I have a set, it blows up. with this error...
[9/20/05 10:27:11:046 CDT] 63e063e0 SystemOut O Hibernate: update EIS001.INCIDENT_PERSON set RB_NUMBER=? where INCIDENT_PERSON_ID=?
[9/20/05 10:27:11:078 CDT] 63e063e0 AbstractFlush E org.hibernate.event.def.AbstractFlushingEventListener Could not synchronize database state with session
[9/20/05 10:27:11:546 CDT] 63e063e0 AbstractFlush E org.hibernate.event.def.AbstractFlushingEventListener TRAS0014I: The following exception was logged org.hibernate.HibernateException: Unexpected row count: 0 expected: 1
Can anyone help me? I am totally new to hibernate, and I have a tight deadline on this project.