could not extract ResultSet;nested exception is org.hibernate.exception.GenericJDBCException: could

could not extract ResultSet; nested exception is org.hibernate.exception.GenericJDBCException: could not extract ResultSet

今天写一个数据修改后的sql如下:
@Modifying
@Transactional
@Query(value = “UPDATE lt_year_study_flag a set a.book_count = ?1,a.city_count = ?2,a.study_time = ?3,a.class_count = ?4,a.goal_text = ?5 where a.train_code = ?6”,nativeQuery = true)
void updateLYStudyFlag(Integer bookCount, Integer cityCount, Integer studyTime, Integer classCount, String goalText, String trainCode);

一直出现好几个类似这样的错could not extract ResultSet; nested exception is org.hibernate.exception.GenericJDBCException: could not extract ResultSet

搞的心态都不好了,查了好几个博主说的都不是我的问题,他们大多数的是自己的数据库字段没有对应上,或者不允许空的字段未传值之类的问题,总之是自己的SQL上的问题,但是我sql检查再三没什么问题。
最后终于排查到了注解,是我没有添加@Transactional 注解和@Modifying 注解。
@Transactional 是声明式事务管理 编程中使用的注解,具体作用请看别人的总结。
@ Modifying 可定义个性化更新操作,例如只涉及某些字段更新时最为常用。

还有一种情况是也是所有检查完之后发现没问题,最后在更新的接收上找到了问题,一般更新的sql直接用void就可以,因为是直接操作数据库。并不需要给后端数据去处理。代码如下:
@Query(value = “UPDATE live_top_bullet a set a.notice_one =?2,a.notice_two =?3,a.notice_thr =?4 where a.live_code =?1”,nativeQuery = true)
viod updateButtleInfo(String liveCode,String noticeOne,String noticeTwo,String noticeThr);

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值