I am not an expert with sleep mode, as indicated in the topic, I have an Object with a collection of objects in it. I tried to use
session.delete(myObject)
and the entity with all its children is correctly deleted from the database.
However, when I run a simple named query:
<query name="deleteByID"> DELETE FROM MyObject o WHERE o.objId IN (:objIds) </query>
And then in code
Query deleteQuery = s.getNamedQuery("deleteByID"); deleteQuery.setParameterList("objIds", objIds); return deleteQuery.executeUpdate();
but only the main object is deleted, and the children remain in the database. The collection is correctly marked as an orphan exception. I wanted to know why this behavior, and if possible, how to achieve a complete deletion using named queries.
source share