JPA: DELETE WHERE does not delete children and throws an exception

后端 未结 5 1100
渐次进展
渐次进展 2020-12-08 14:42

I am trying to delete a large number of rows from MOTHER thanks to a JPQL query.

The Mother class is defined as follows:

@E         


        
5条回答
  •  南笙
    南笙 (楼主)
    2020-12-08 15:01

    This is related and may offer a solution if you're using Hibernate.

    JPA CascadeType.ALL does not delete orphans

    EDIT

    Since Oracle is the one giving you the error you could maybe make use of the Oracle cascade delete to get around this. However, this could have unpredictable results: since JPA doesn't realize that you're deleting other records those objects could remain in the cache and be used even though they've been deleted. This only applies if the implementation of JPA you are using has a cache and is configured to use it.

    Here is info on using cascade delete in Oracle: http://www.techonthenet.com/oracle/foreign_keys/foreign_delete.php

提交回复
热议问题