79475606

Date: 2025-02-28 13:04:21
Score: 0.5
Natty:
Report link

I have been working with Oracle and PostgreSQL, and I can confirm that neither of them supports table aliases in the SET clause, nor do they allow direct UPDATE with JOIN. Which database are you using?

I recommend rewriting your UPDATE statement using a subquery, like this:

@Modifying
@Query("UPDATE ActivityEnvironmentRelation aer "
       + "SET aer.isDeleted = 1, aer.updatedBy = :updatedBy "
       + "WHERE aer.activity.id IN ("
       + "  SELECT a.id FROM Activity a WHERE a.project.objectId = :projectId"
       + ")")
void deleteActivityEnvironments(@Param("projectId") Long projectId, @Param("updatedBy") User updatedBy);
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Oleg Cheban