休眠 - 批量更新返回来自更新的意外行数:0实际行数:0预期:1 [英] Hibernate - Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
问题描述
org.hibernate.StaleStateException:批量更新从更新中返回意外的行数:0实际行数:0预期:1个
。在org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java:93)
。在org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:79)
。在在在org.hibernate.engine org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
。在org.hibernate.engine.ActionQueue.executeActions ActionQueue.executeActions(ActionQueue.java:235)
(ActionQueue.java:142)
在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)处org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:584)
(AbstractPlatformTransacti
onManager
。 Java的:500)
在org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManag
er.java:473)
在org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(交易
AspectSupport.java:267)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvoca tion.proceed(ReflectiveMethodInvocation.java:170)
。在org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
如果您的交易没有代码和映射,那么调查问题几乎是不可能的。
但是,为了更好地处理导致问题的原因,请尝试以下操作:
希望有帮助。
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:
- In your hibernate configuration, set hibernate.show_sql to true. This should show you the SQL that is executed and causes the problem.
- Set the log levels for Spring and Hibernate to DEBUG, again this will give you a better idea as to which line causes the problem.
- Create a unit test which replicates the problem without configuring a transaction manager in Spring. This should give you a better idea of the offending line of code.
Hope that helps.
这篇关于休眠 - 批量更新返回来自更新的意外行数:0实际行数:0预期:1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!