I'm trying to execute the following bulk delete using jpql:
" DELETE " +
" FROM AutAnt aa " +
" JOIN aa.person p " +
" JOIN p.employees e" +
" WHERE e = :employess " +
" AND (" +
" aa.dateFrom BETWEEN :dateStart AND :dateEnd" +
" OR" +
" aa.dateTor BETWEEN :dataStart AND :dateEnd" +
" )");
But I'm getting this error:
unexpected token: JOIN
The JPA docs state that "Delete by query uses the same JPQL syntax as normal queries, with one exception: begin your query string with the delete keyword instead of the select keyword"
I have the following select query which works perfectly:
" SELECT aa " +
" FROM AutAnt aa " +
" JOIN aa.person p " +
" JOIN p.employees e" +
" WHERE e = :employess " +
" AND (" +
" aa.dateFrom BETWEEN :dateStart AND :dateEnd" +
" OR" +
" aa.dateTor BETWEEN :dataStart AND :dateEnd" +
" )");
Changing the first statement of the delete query to "DELETE aa" raises a different exception.
Is this a Hibernate bug, or am I missing something here.
Cheers!