JPA , Not supported for DML operations

在使用 JPA 的 @Query 自定义持久层方法时,运行报错:

错误日志:

Not supported for DML operations

解决办法:
在方法上增加 @Modifying 注解。

	@Modifying
    @Query(value = "UPDATE qtapd_project SET project_status = :status WHERE project_id = :projectId")
    Integer updateProjectStatus(@Param("projectId") Integer projectId, @Param("status") Integer status);

运行,依然报错,错误日志:

Executing an update/delete query
在这里插入图片描述

解决办法:
在业务类 Service 类上,增加事务注解 @Transaction

发布了19 篇原创文章 · 获赞 5 · 访问量 2625

猜你喜欢

转载自blog.csdn.net/weixin_36908494/article/details/103852013
DML
JPA