This is an extension of this question Update Statement with JOIN in SQL but I am trying to use Spring Data JPQL.
I am trying to use Update along with JOIN in JPQL as follows
@Modifying
@Query("UPDATE TotalValue tv JOIN LineItems li WHERE li.totalValue.totalValueId=:totalValuedId SET tv.totalAmount =sum(li.itemTotalValue) ")
void calculateTotalAmount(@Param("totalValuedId") Long totalValuedId);
However, i get an error as follows
org.hibernate.hql.internal.ast.QuerySyntaxException: expecting "set", found 'JOIN'
Is UPDATE and JOIN not possible in JPQL ? What is the alternative. Thanks
The JPQL syntax seems to indicate that a JOIN is actually not possible in an UPDATE statement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With