加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

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

发布时间:2020-12-12 16:25:25 所属栏目:MsSql教程 来源:网络整理
导读:我尝试将以下代码添加到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.inter
我尝试将以下代码添加到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)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读