Why this is working:
@Query("from Ban b where b.banned.uuid = :uuid")
but this cause SQL syntax error:
@Query("delete Ban b where b.banned.uuid = :uuid")
Error message is: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'cross join user user1_ where uuid=x'53......'' at line 1
CodePudding user response:
Neither HQL nor, usually—at least as far as I know—SQL, supports joins in delete
statements. However, you can emulate it with a subquery, something like:
delete Ban b where b.bannedid = (select bb.id from Banned bb where bb.uuid = :uuid)