I cant seems to delete a parent class with a subclass with an array mapping of Strings. I am using mysql 5.0. and issue the following command
delete com.model.AutoResumeQueryParams where id in (1,2,3);
It just throw a foreign key constraint error, I checked the contraint error against the database and is it definitely the array mapping. how come the array data is not deleted first with cascade?
I already try every cascade option like all and all-delete-orphan but still the same thing.
here is the mapping file
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.model.AutoResumeQueryParams" table="auto_query_params" discriminator-value="B">
<id name="id" column="id" unsaved-value="null">
<generator class="increment"/>
</id>
<discriminator column="QUERY_TYPE" type="string"/>
<property name="queryName"/>
<set name="autoTriggers" table="trigger_queryparams" inverse="true" cascade="all" lazy="true">
<key column="auto_param_id"/>
<many-to-many column="auto_trigger_id" class="com.model.AutoScheduleJobTrigger"/>
</set>
<set name="autoCandidates" table="candidates_queryparams" inverse="true" cascade="all" lazy="true">
<key column="auto_param_id"/>
<many-to-many column="auto_cand_id" class="com.model.AutoCandidate"/>
</set>
</class>
<subclass name="com.model.AutoSubParams" extends="com.model.AutoResumeQueryParams" discriminator-value="D">
<property name="query"/>
<array name="country" table="sub_country" cascade="all-delete-orphan">
<key column="query_params_id" not-null="true"/>
<index column="arrayindex"/>
<element type="java.lang.String"></element>
</array>
</subclass>
</hibernate-mapping>