一、问题由来
今天在个人博客网站前后端全部写完进行功能测试的时候发现一个问题,在通过改变文章状态来删除文章的时候出现了个问题
// 无法使用ecuteQuery()发出数据操作语句。
[2020/09/27-23:50:50] [http-nio-8000-exec-6] [ERROR] [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] : Can not issue data manipulation statements with executeQuery().
二、解决方案
其实解决的方法很简单 执行修改查询,而这些查询实际上只需要参数绑定,方法是将查询方法注释为@Modifying:
@Modifying
@Query(nativeQuery = true, value = "update `tb_article` set `state` = 0 where `id` = ?")
int deleteArticleByState(String articleId);
问题解决