Hello,
I've got a class with a collection in it and it's mapped in hibernate with a one-to-many relationship. Everything there is pretty standard.
Code:
<class name="CState" entity-name="CState" table="c_state">
<cache usage="read-write" />
<id name="id" type="long" column="c_device_id">
<generator class="foreign">
<param name="property">state</param>
</generator>
</id>
<set name="alarms" cascade="none" inverse="true" order-by="character_position asc">
<cache usage="read-write" />
<key column="c_device_id" not-null="true" />
<one-to-many entity-name="Alarm" />
</set>
<property name="lastModified" type="timestamp" column="last_mod_date_ts" />
<property name="created" type="timestamp" column="create_date_ts" />
</class>
<!-- Alarm -->
<class name="Alarm" entity-name="Alarm" table="alarm_state">
<cache usage="read-write" />
<id name="id" type="long" column="alarm_state_id">
<generator class="sequence">
<param name="sequence">alarm_state_seq</param>
</generator>
</id>
<property name="cId" type="long" column="c_device_id" not-null="true" />
<property name="displayChar" type="string" column="alarm_display_character" />
<property name="lastModified" type="timestamp" column="last_mod_date_ts" />
<property name="created" type="timestamp" column="create_date_ts" />
</class>
If there is a change in the alarm collection, and I do an update on the parent, the parent object is updated as well as the child object. Nothing has changed in the parent object except the last mod date, which adds a record in a history table via DB trigger.
I'm looking for a way to
not update the parent when only a child is changed.
This may seem a bit strange, seeing as how I've found nothing on the web about it, however I'd still like to be able to do this. We're sort of locked in to a situation like this, so fundamental changes are currently impossible with our time constraints.
Thanks