美文网首页
org.hibernate.StaleStateExceptio

org.hibernate.StaleStateExceptio

作者: 1ff5a98e5398 | 来源:发表于2018-12-06 22:07 被阅读16次

说明

使用spring data jpa的deleteAll功能,报错

org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

从控制台的打印看

delete 
    from
        sms_code_record 
    where
        id = ?
        and version = ?

这条sql是有问题的,具体原因还没有查明

解决

手写HQL

    @Transactional
    @Modifying
    @Query("delete from SmsCodeEntity e where e.id in (:ids)")
    int deleteAllByIdIn(@Param("ids") List<Integer> ids);

相关文章

网友评论

      本文标题:org.hibernate.StaleStateExceptio

      本文链接:https://www.haomeiwen.com/subject/hhbacqtx.html