I've got an infoset which contains a set of infosetDocuments:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin
http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class
name="com.potomacfusion.vid.dao.Infoset"
table="infoset"
>
<meta attribute="generated-class">com.potomacfusion.vid.dao.InfosetDTO</meta>
<id name="id" type="string" unsaved-value="null" >
<column name="infoset_id" sql-type="char(32)"
not-null="true"/>
<generator class="uuid.hex"/>
</id>
<property
name="infosetName"
type="java.lang.String"
column="infoset_name"
length="255"
/>
<property
name="graphData"
type="java.lang.String"
column="graph_data"
length="2147483647"
/>
<!-- associations -->
<one-to-one name="query"
class="com.potomacfusion.vid.dao.Query" property-ref="infoset">
</one-to-one>
<set name="infosetDocuments" table="infoset_document_assn" inverse="true" cascade="all">
<key column="infoset_id" />
<one-to-many class="com.potomacfusion.vid.dao.InfosetDocumentAssn" />
</set>
</class>
</hibernate-mapping>
InfosetDocument relate a documents to multiple infosets:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin
http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class
name="com.potomacfusion.vid.dao.InfosetDocumentAssn"
table="infoset_document_assn"
>
<meta attribute="generated-class">com.potomacfusion.vid.dao.InfosetDocumentAssnDTO</meta>
<!-- A 32 hex character is our surrogate key. It's automatically
generated by Hibernate with the UUID pattern. -->
<id name="id" type="string" unsaved-value="null" >
<column name="id" sql-type="char(32)" not-null="true"/>
<generator class="uuid.hex"/>
</id>
<property name="infosetId" type="java.lang.String" insert="false" update="false">
<column name="infoset_id" sql-type="char(32)" not-null="true"/>
</property>
<property name="documentId" type="java.lang.String" insert="false" update="false">
<column name="document_id" sql-type="char(32)" not-null="true"/>
</property>
<!-- associations -->
<many-to-one name="infoset" column="infoset_id" class="com.potomacfusion.vid.dao.Infoset"/>
<many-to-one name="document" column="document_id" class="com.potomacfusion.vid.dao.Document" cascade="save-update"/>
</class>
</hibernate-mapping>
When I try and delete an infoset I see the follow:
Hibernate: delete from infoset_document_assn where id=?
Hibernate: delete from infoset where infoset_id=?
WARN [21:32:55] (JDBCExceptionReporter.java:38) - SQL Error: 1217, SQLState: S1000
ERROR [21:32:55] (JDBCExceptionReporter.java:46) - General error, message from server: "Cannot delete or update a parent row: a foreign key constraint fails"
The problem seems to be that the delete from infoset_document_assn is using the wrong key 'id' instead of what I thought it should 'infoset_id' as configured in the infosetDocuments 'set' element. Can anyone help me understand what I've done wrong and how I can fix it?
Thanks
Ted