I tries to add following code to spring data jpa repository:
我尝试将以下代码添加到spring数据jpa存储库:
@Query("insert into commit_activity_link (commit_id, activity_id) VALUES (?1, ?2)")
void insertLinkToActivity(long commitId, long activityId);
But app can't start with exception:
但app不能以例外开头:
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)]
引起:org.hibernate.hql.internal.ast.QuerySyntaxException:意外令牌:VALUES靠近第1行第59列[insert into commit_activity_link(commit_id,activity_id)VALUES(?1,?2)]
Where i'm wrong?
哪里我错了?
1 个解决方案
#1
23
I had to add nativeQuery = true
to @Query
我不得不在@Query中添加nativeQuery = true
@Query(value = "insert into commit_activity_link (commit_id, activity_id) VALUES (?1, ?2)", nativeQuery = true)
#1
23
I had to add nativeQuery = true
to @Query
我不得不在@Query中添加nativeQuery = true
@Query(value = "insert into commit_activity_link (commit_id, activity_id) VALUES (?1, ?2)", nativeQuery = true)