错误信息:
部分错误信息:
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);这样问题就可以迎刃而解了。
