使用JPA去做删除操作,除了remove外很容易想到下面这种做法: @Query("delete from Model t where t.id=:id")public void doDelete(int id); 但上面这个写法会delete失败,加上两个注解即可,如下: @Modifying@Transactional@Query("delete from Model t where t.id=:id")public void doDelete(int id);