Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Hibernate 3.2.2
Mapping documents:
<class name="ContentItem" table="CMS_ContentItem">
<cache usage="read-write"/>
<id name="id" column="id" type="integer" unsaved-value="0">
<generator class="native"/>
</id>
<property name="title"/>
<property name="description" type="text"/>
<set name="outboundLinks" table="CMS_ContentItem_ContentItem" cascade="none" >
<cache usage="read-write"/>
<key column="id"/>
<many-to-many column="link_id" class="ContentItem"/>
</set>
<set name="inboundLinks" table="CMS_ContentItem_ContentItem" cascade="none" inverse="true">
<cache usage="read-write"/>
<key column="link_id"/>
<many-to-many column="id" class="ContentItem"/>
</set>
</class>
Code between sessionFactory.openSession() and session.close():
hibernateTemplate.delete(contentItem);
Name and version of the database you are using:
MySQL 5.0.5
Debug level Hibernate log excerpt:
Integrity Constraint Violation
So here is the challenge:
I am writing a content management system and allowing users to link content together.
The problem is when I attempt to delete the object only that objects outbound links are being deleted.
After Hibernate deletes the objects outbound links it fails on an integrity constraint because other objects might still have outbound links pointing to it (represented as the invest inbound links collection).
What is the best way of dealing with this type of association?
Can hibernate handle this type of association where a primary key can appear in either column of the composite table?
Thanks