sql – 在hibernate spring数据中的本机插入查询

前端之家收集整理的这篇文章主要介绍了sql – 在hibernate spring数据中的本机插入查询前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我尝试将以下代码添加到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)
原文链接:https://www.f2er.com/mssql/83414.html

猜你在找的MsSQL相关文章