hibernate + spring数据中的本机插入查询

mis*_*hka 14 sql hibernate spring-data

我尝试将以下代码添加到spring数据jpa存储库:

  @Query("insert into commit_activity_link (commit_id, activity_id) VALUES (?1, ?2)")
  void insertLinkToActivity(long commitId, long activityId);
Run Code Online (Sandbox Code Playgroud)

但app不能以例外开头:

引起:org.hibernate.hql.internal.ast.QuerySyntaxException:意外令牌:VALUES靠近第1行第59列[insert into commit_activity_link(commit_id,activity_id)VALUES(?1,?2)]

哪里我错了?

mis*_*hka 33

我不得不添加nativeQuery = true@Query

@Query(value = "insert into commit_activity_link (commit_id, activity_id) VALUES (?1, ?2)", nativeQuery = true)
Run Code Online (Sandbox Code Playgroud)