I've got an object, a Transfer. I have TransferEvents I add to it and these are sorted by the timestamp of the event.
Why when I save the Transfer it INSERTs the new TransferEvent as expected. Yet Hibernate then also UPDATEs every TransferEvent as well. Why?
Is there something I've done wrong in defining the set in the hibernate mapping?
Hibernate version:
2.1
Mapping documents:
<class name="Transfer">
<id name="id" column="ID">
<generator class="native" />
</id>
<set name="events" cascade="all" sort="natural" inverse="true" >
<key column="TRANSFER_ID" foreign-key="FK_TRANSFER_EVENTS"/>
<one-to-many class="com.ncube.nable.platform.transfer.TransferEvent"/>
</set>
</class>
<class name="TransferEvent">
<id name="id" column="ID">
<generator class="native" />
</id>
<property name="message" />
<property name="eventTime" type="com.ncube.nable.platform.hibernate.DateTimeType" />
<property name="eventTypeName" />
<many-to-one name="transfer" column="TRANSFER_ID" cascade="none" not-null="true" />
</class>
SQL
14:25:19,380 DEBUG SQL:226 - insert into MC.TransferEvent (message, eventTime, eventTypeName, TRANSFER_ID, ID) values (?, ?, ?, ?, null)
14:25:19,380 DEBUG SQL:226 - call identity()
14:25:19,395 DEBUG hibernate:243 - Committing database transaction of this thread.
14:25:19,395 DEBUG SQL:226 - update MC.TransferClient set clientId=? where ID=?
14:25:19,395 DEBUG SQL:226 - update MC.Transfer set transferEnabled=?, status=?, created=?, priority=?, savedState=?, attempts=?, destHost=?, destFile=?, destUsername=?, destPassword=?, sourceHost=?, sourceFile=?, sourceUsername=?, sourcePassword=?, isCancelable=?, cancelOnRestart=?, transferReason=? where ID=?
14:25:19,395 DEBUG SQL:226 - update MC.TransferEvent set message=?, eventTime=?, eventTypeName=?, TRANSFER_ID=? where ID=?
14:25:19,395 DEBUG SQL:226 - update MC.TransferEvent set message=?, eventTime=?, eventTypeName=?, TRANSFER_ID=? where ID=?
14:25:19,395 DEBUG SQL:226 - update MC.TransferEvent set message=?, eventTime=?, eventTypeName=?, TRANSFER_ID=? where ID=?
Last edited by ckessel on Wed Oct 04, 2006 11:16 am, edited 1 time in total.
|