Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
2.1.7
Mapping documents:
<hibernate-mapping>
<class name="com.XmlFieldGroupTemplate" table="xmlfieldGroup" optimistic-lock="version" dynamic-update="true">
<id name="id" type="string" unsaved-value="null">
<column name="id" length="16"/>
<generator class="assigned"/>
</id>
<version name="version" column="version" unsaved-value="negative"/>
<array name="xmlFields" table="xmlgroupfields" cascade="all">
<key>
<column name="groupid" not-null="false"/>
</key>
<index column="idx"/>
<one-to-many class="com.XmlGroupFieldTemplate"/>
</array>
<class name="com.XmlGroupFieldTemplate" table="xmlgroupfields" optimistic-lock="version" dynamic-update="true">
<id name="id" type="string" unsaved-value="null">
<column name="id" length="16"/>
<generator class="assigned"/>
</id>
<version name="version" column="version" unsaved-value="negative"/>
<property name="nodeType" column="nodetype" type="string"/>
<property name="name" column="fieldname" type="string"/>
<many-to-one outer-join="false" name="parent" class="com.XmlGroupFieldTemplate" cascade="none" not-null="false">
<column name="parentid" sql-type="varchar(32)" not-null="false"/>
</many-to-one>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
session.update(this)
Full stack trace of any exception that occurs:
Name and version of the database you are using:
Oracle 9.2.0.4.0
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Is there any way to simulate all-delete-orphan behaviour for Hibernate arrays, similar to other collections? As you can see from the mapping file, when I remove an instance of XmlGroupFieldTemplate from the collection the record for the same is not deleted from the database. Instead, the group ID is just updated to null.
This behaviour is not very favorable, since if I later on add an instance of XmlGroupFieldTemplate to the collection with the same id, then it causes an unique index constraint violation(because it tries to insert the record again).
Thanks.