我尝试将以下代码添加到spring数据jpa存储库:
@Query("insert into commit_activity_link (commit_id,activity_id) VALUES (?1,?2)") void insertLinkToActivity(long commitId,long activityId);
但app不能以例外开头:
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: VALUES near line 1,column 59 [insert into commit_activity_link (commit_id,?2)]
哪里我错了?
解决方法
我不得不在@Query中添加nativeQuery = true
@Query(value = "insert into commit_activity_link (commit_id,?2)",nativeQuery = true)