Ok, I explain it with a simple extract of my model.
I have a class named "Document", that has an attribute "properties", which is a map. The model is mapped with hbm2ddl to my database, so that there is a table for "Document" and one for "properties". The last one has a "Document" id as foreign id (see simple mapping extract below).
The problem is now, that when I use bulk delete (
http://www.hibernate.org/hib_docs/v3/re ... tch-direct) to delete many document objects at once ("delete Document as doc where doc.id in (:ids)"), I get an foreign key exception, as bulk delete doesn't seems to cascade delete.
I just also found this posting here:
http://forum.hibernate.org/viewtopic.ph ... ulk+delete
So it really seems, that bulk delete is not able to cascade delete objects including their dependencies.
My problem is even a bit more problematic than in the posting above, as I can't delete the "properties" directly, cause those a no directly named entities and so I can't access them directly.
Is there another option for deleting a large number of objects at once? For having a list of id's, fetching each object by id and then deleting it, isn't an option as it takes far too much time.
Any suggestions?
Kai
extract from the hibernate mapping file:
<class name="org.pubcurator.documentor.documentmodel.impl.DocumentImpl" entity-name="Document" abstract="false" lazy="false" discriminator-value="Document" table="`document`">
<meta attribute="eclassName">Document</meta>
<meta attribute="epackage">http://www.pubcurator.org/documentor/documentmodel</meta>
<id name="id" type="long" unsaved-value="0">
<column not-null="true" unique="false" name="`id`"/>
<generator class="native"/>
</id>
<discriminator column="`dtype`" type="string"/>
<version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler">
<meta attribute="syntheticVersion">true</meta>
</version>
<map name="properties" lazy="true" cascade="all,delete-orphan">
<key update="true">
<column name="`document_properties_id`" not-null="false" unique="false"/>
</key>
<map-key type="java.lang.String"/>
<element type="java.lang.String" not-null="false" unique="false">
<column not-null="false" unique="false" name="`value`" length="10000"/>
</element>
</map>
</class>