错误信息:
部分错误信息:
org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.hql.internal.QueryExecutionRequestException: Not supported for DML operations [delete from com.lsc.pojo.User u where u.id=?1]; nested exception is java.lang.IllegalStateException: org.hibernate.hql.internal.QueryExecutionRequestException: Not supported for DML operations [delete from com.lsc.pojo.User u where u.id=?1]
出现这个错误的原因是因为我的自定义方法中没有加入 @Modifying这个注解。
//删除用户
@Transactional
@Query("delete from User u where u.id=?1")
int DeleteUser(int id);
只要把@Modifying注解加上
//删除用户
@Modifying
@Transactional
@Query("delete from User u where u.id=?1")
int DeleteUser(int id);
这样问题就可以迎刃而解了。
版权声明:本文为weixin_45255645原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。