문제

I have the following mapping in hibernate:

    <class name="com.foo.bulk_delete.test3.lim.bl.pom.impl.P4" table="P4_BDELETE">
    <list lazy="false" fetch="select" batch-size="25" name="strings" table="L_st_49eea" >
        <key>
            <column name="f_oid$1" index="I_oid$_49eea" sql-type="char(35)"/>
        </key>
        <index column="s_idx$"/>
        <element type="VarcharStringType">
            <column name="s_elem$_5eb03"  length="512"/>
        </element>
    </list>
</class>

if I want to delete all P4 elements in hql i do something similar to

delete from com.foo.bulk_delete.test3.lim.bl.pom.impl.P4 p4

but obviously I have a constraint violation exception because I need to delete the inner "L_st_49eea" table but I don't know how to do it in hql.

도움이 되었습니까?

해결책

You cannot do this via HQL alone.. you have to first delete the referenced entities and then delete the parent entity.
I would recommend to use delete cascade along with the foreign key constraint and then you can delete via simple HQL on parent.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top