Hi,
I am trying to delete an object which has collection of child objects. The main object has some not null fields that Hibernate tries to update to null before delete. This causes error: SEVERE: Could not synchronize database state with session
java.sql.BatchUpdateException: ORA-01407: cannot update ("MYPROJECT"."USER_VIEWS"."NAME") to NULL.
I have seen a very similar posting where the answer was to set the many side (child objects) setting inverse="true". However, I do not know how to do this, because many-to-one column belongs to the composite-id of the child object.
Here are my mappings:
<class name="View" table="user_views">
<id name="id" type="string" column="user_view_id" unsaved-value="0">
<generator class="uuid.hex">
</generator>
</id>
<property name="name" type="string" not-null="true"/>
<property name="viewTypeName" type="string" column="uvie_type" not-null="true"/>
<property name="description" type="string"/>
<property name="maxAmount" type="integer" column="max_amount"/>
<property name="owner" type="string"/>
<set name="sortBys" table="user_view_sort" inverse="true" cascade="all-delete-orphan">
<key column="user_view_id"/>
<one-to-many class="SortBy"/>
</set>
</class>
<class name="SortBy" table="user_view_sorts">
<composite-id>
<key-property name="column" type="ColumnType" column="column_name"/>
<key-many-to-one name="view" class="View" column="user_view_id"/>
</composite-id>
<property name="ascending" type="boolean" column="is_asc"/>
<property name="index" type="integer" column="uvis_index"/>
</class>
|