I have an entityrelation like this:
In the ParentObj class:
@OneToMany(mappedBy = \"parentObj\", fetch = FetchType.EAGER, cascade = CascadeType.ALL,
The following
em.createQuery("DELETE FROM ParentObj po").executeUpdate();
is a JPQL bulk update command and as the JPQL language reference notes:
10.2.9. JPQL Bulk Update and Delete
Operations Bulk update and delete operations apply to entities of a single entity class (together with its subclasses, if any).
A delete operation only applies to entities of the specified class and its subclasses. It does not cascade to related entities.....
https://docs.oracle.com/html/E24396_01/ejb3_langref.html#ejb3_langref_bulk_ops
So essentially you are attempting to remove an entity which, due to lack of cascading, will still have FK references in the database. Hence the exception.
CriteriaDelete has similar limitations:
https://docs.oracle.com/javaee/7/api/javax/persistence/criteria/CriteriaDelete.html
Criteria API bulk delete operations map directly to database delete operations. The persistence context is not synchronized with the result of the bulk delete.