Reputation: 3204
I have three related entities
public class EntityA
{
private Long id;
}
public class EntityB
{
private Long id;
private EntityA entityA;
private EntityC entityC;
}
public class EntityC
{
private Long id;
}
Query query = persistenceManager.createNamedQuery("DELETE FROM EntityB a WHERE a.entityA = :entityA AND a.entityC.id in :entityCList");
query.setParameter("entityA", entityAObj);
query.setParameter("entityCList", entityCList);
query.executeUpdate();
I am using MySQL database. The parameter :entityCList
is an ArrayList
of entityC ids
i.e. List<Long> entityCList
and :entityA
is an Object of EntityA
.
When i ran the delete query above, the records did not delete from the database and it did not throw an exception. What could be wrong with the query.
Upvotes: 2
Views: 124
Reputation: 18389
What was the SQL generated?
Try comparing entityC to a list of EntityC objects instead of ids.
Or, try using a sub-select, instead of a join.
Upvotes: 1