如果是下面错误,则需要在相应的方法上加上@Modifying
java.sql.SQLException:Can not issue data manipulation statements with executeQuery()
例如:
@Modifying
@Query(value = "UPDATE aa SET delete = 1 WHERE id = :id", nativeQuery = true)
int a(@Param(value = "id")Integer id);
然后需要在相应的service加上注解@Transactional,否则会报以下错误
Caused by: javax.persistence.TransactionRequiredException: Executing an update/delete query