休眠 - 批量更新从更新返回意外的行数:0 实际行数:0 预期:1 [英] Hibernate - Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1

查看:36
本文介绍了休眠 - 批量更新从更新返回意外的行数:0 实际行数:0 预期:1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下休眠错误.我能够确定导致问题的功能.不幸的是,函数中有几个 DB 调用.由于休眠在事务结束时刷新会话,因此我无法找到导致问题的行.下面提到的休眠错误看起来像一个一般错误.它甚至没有提到哪个 Bean 导致了这个问题.有人熟悉这个休眠错误吗?

I get following hibernate error. I am able to identify the function which causes the issue. Unfortunately there are several DB calls in the function. I am unable to find the line which causes the issue since hibernate flush the session at the end of the transaction. The below mentioned hibernate error looks like a general error. It doesn't even mentioned which Bean causes the issue. Anyone familiar with this hibernate error?

org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
        at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java:93)
        at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:79)
        at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
        at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:142)
        at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
        at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
        at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
        at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:584)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransacti
onManager.java:500)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManag
er.java:473)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(Transaction
AspectSupport.java:267)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)

推荐答案

如果没有交易的代码和映射,几乎不可能调查问题.

Without code and mappings for your transactions, it'll be next to impossible to investigate the problem.

但是,要更好地了解导致问题的原因,请尝试以下操作:

However, to get a better handle as to what causes the problem, try the following:

  • 在您的休眠配置中,将 hibernate.show_sql 设置为 true.这应该会向您显示已执行并导致问题的 SQL.
  • 将 Spring 和 Hibernate 的日志级别设置为 DEBUG,这同样会让您更好地了解哪一行导致了问题.
  • 创建一个单元测试来复制问题,而无需在 Spring 中配置事务管理器.这应该能让您更好地了解有问题的代码行.

希望有所帮助.

这篇关于休眠 - 批量更新从更新返回意外的行数:0 实际行数:0 预期:1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆