当前位置: 代码迷 >> 综合 >> Either use @Param on all parameters except Pageable and Sort type once, or none at all
  详细解决方案

Either use @Param on all parameters except Pageable and Sort type once, or none at all

热度:81   发布时间:2023-11-27 14:37:36.0

Spring Data Jpa在使用是出现错误

java.lang.IllegalArgumentException:Either use @Param on all parameters except Pageable and Sort typed once, or none at all
@Modifying
@Transactional
@Query("update Post set views = views + :increment where id = :id")
void updateViews(long id, @Param("increment") int increment);

少加了个@Param

改为

@Modifying
@Transactional
@Query("update Post set views = views + :increment where id = :id")
void updateViews(@Param("id")long id, @Param("increment") int increment);
  相关解决方案