Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I try to add the following code to a spring data jpa repository:

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

But an app can't start with the exception:

Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: VALUES near line 1, column 59 [insert into commit_activity_link (commit_id, activity_id) VALUES (?1, ?2)]

Where am I wrong?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
592 views
Welcome To Ask or Share your Answers For Others

1 Answer

I had to add nativeQuery = true to @Query

@Query(value = "insert into commit_activity_link (commit_id, activity_id) VALUES (?1, ?2)", nativeQuery = true)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...