带postgresql的spring boot jpa错误:返回的结果不是预期的结果

hwamh0ep  于 2021-07-26  发布在  Java
关注(0)|答案(0)|浏览(202)

我使用postgresql和springdatajpa执行更新,如下所示

@Transactional
@Modifying(flushAutomatically = true, clearAutomatically = true)
@Query(
     "UPDATE posts SET comments_count = comments_count +1 WHERE post_id = :postId RETURNING comments_count",
      nativeQuery = true
)
fun incrementCommentCounter(@Param("postId") postId: Long): Int

当我使用本机查询时 RETURNING 子句,它抛出异常

o.h.engine.jdbc.spi.SqlExceptionHelper   : A result was returned when none was expected.

我应该如何用spring boot执行这个查询?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题