Note that we use JPA with Hibernate as our JPA provider.
I have two tables
TeamMember
Task
A teammember has many tasks. The task table has a foreign key column to the teammember.memberid. My task entity, however, does not include this column as a field in the entity.
I am trying to do a batch delete with the following syntax:
DELETE FROM Task t WHERE t.teammember.memberid = 'mymemberid'
This is the generated syntax:
Hibernate: delete from Task, TeamMember teammember1_ where memberid=?
I get an SQLGrammerException (on oracle, postgres and mysql).
The hibernate documentation (Reference 13.4 DML-style operations)seems pretty clear that no joins (implicit or explicit) can be specified in a bulk HQL query.
I could not find the same restrictions in the JPQL specification which I thought was a subset of HQL. Is this a restriction with hibernate but not with JPQL or am I missing something in the JPQL specification?
Is there a better way to delete all of the children of an entity with only the parent tables identifier?
|