Same issue with subqueries in JPQL UPDATE. UPDATE Address AS a SET a.version = a.version + 1, a.population = a.population - (SELECT SUM(dept.num) FROM Departure dep, IN(dep.addresses) depa WHERE depa = a AND dep.date = :date ) WHERE .... This JPQL transalated to SQL with "WHERE addresses2_.entityKey = entityKey" in the "SUM" subquery. While should be something like "WHERE addresses2_.entityKey = addresses1_entityKey". Where addresses1_ is an alias for table in the "UPDATE" clause. |