简体   繁体   English

Spring&Hibernate:无法将数据库状态与会话同步

[英]Spring & Hibernate : Could not synchronize database state with session

I am getting following exception, kindly help me.... 我正在追随异常,请帮忙...。

    (AbstractFlushingEventListener.java:324) - Could not synchronize database state with session
org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.xxx.exx.rxx.entity.CallSignStatusEntity#21123]
    at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1934)
    at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2578)
    at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2478)
    at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2805)
    at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:114)
    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:267)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:259)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:179)
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
    at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:64)
    at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1175)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1251)
    at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
    at org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:921)
    at org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:1)
    at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
    at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
    at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:912)
    at com.xxx.exx.rxx.dao.hibernate.CallxxxDaoImpl.getCallxxxStatusOfLoginOfficer(CallxxxDaoImpl.java:244)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    at $Proxy809.getCallSignStatusOfLoginOfficer(Unknown Source)
    at com.xxx.exx.rxx.business.impl.OfficerManagerImpl.getOfficerCallxxxBasic(OfficerManagerImpl.java:438)
    at com.xxx.exx.rxx.business.impl.OfficerManagerImpl.getUserCallxxxBasicInfo(OfficerManagerImpl.java:757)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    at $Proxy875.getUserCallxxxBasicInfo(Unknown Source)
    at com.xxx.exx.ims.util.OperationsPlanUtil.getUserCallxxxName(OperationsPlanUtil.java:1203)
    at com.xxx.exx.ims.business.impl.IncidentFolderManagerImpl.createIncidentEventLogForCreateIncident(IncidentFolderManagerImpl.java:635)
    at com.xxx.exx.ims.business.impl.IncidentFolderManagerImpl.createIncidentEventLog(IncidentFolderManagerImpl.java:771)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196)
    at $Proxy870.createIncidentEventLog(Unknown Source)
    at com.xxx.exx.rxx.business.impl.EventLogManagerImpl.insertIncidentEventLog(EventLogManagerImpl.java:210)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    at $Proxy876.insertIncidentEventLog(Unknown Source)
    at com.xxx.exx.rxx.business.impl.CallxxxStatusManagerImpl.logIncidentResourceStatusUpdate(CallxxxxStatusManagerImpl.java:524)
    at com.xxx.exx.rxx.business.impl.CallxxxStatusManagerImpl.handleCallxxxStatus2Available(CallxxxxStatusManagerImpl.java:286)
    at com.xxx.exx.rxx.business.impl.CallxxxxStatusManagerImpl.updateCallxxxxToStatus(CallxxxxStatusManagerImpl.java:146) 

Most important stuff you need to look at in your stacktrace is 您需要在堆栈跟踪中查看的最重要的内容是

org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) org.hibernate.StaleObjectStateException:行已由另一个事务更新或删除(或未保存的值映射不正确)

This gives you enough indication what could be going wrong underneath. 这可以为您提供足够的指示,说明可能在下面的地方出了问题。 As mentioned in the trace you have two possibilities 如跟踪中所述,您有两种可能

  1. The row you are trying to update was modified by some other source and the copy you have is not the updated one. 您尝试更新的行已由其他来源修改,而您拥有的副本不是已更新的副本。 So your changes were discarded and this exception was thrown. 因此,您所做的更改被放弃,并引发了此异常。 If this is the issue, you must start looking at locking mechanisms. 如果这是问题所在,则必须开始研究锁定机制。 By default hibernate uses optimistic locking. 默认情况下,休眠使用乐观锁定。

  2. Mapping corresponding to the object you are trying to save is incorrect. 与您要保存的对象相对应的映射不正确。

My guess is, your application will have first issue but still you need to verify and find out the exact cause. 我的猜测是,您的应用程序将是第一个问题,但是仍然需要验证并找出确切原因。

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在Grails Hibernate中将数据库状态与会话错误同步 - Could not synchronize database state with session Error in Grails Hibernate Vaadin Spring 和 Hibernate:无法初始化代理 - 否 Session - Vaadin Spring and Hibernate: could not initialize proxy - no Session LazyInitializationException:无法初始化代理-Spring和Hibernate中没有会话 - LazyInitializationException: could not initialize proxy - no Session in Spring and Hibernate Spring MVC + Hibernate:无法初始化代理 - 没有Session - Spring MVC + Hibernate: could not initialize proxy - no Session Hibernate / Spring3:无法初始化代理 - 没有Session - Hibernate/Spring3: could not initialize proxy - no Session Spring DATA JPA + Hibernate-无法初始化代理-修复后无会话: - Spring DATA JPA + Hibernate - could not initialize proxy - no Session after fix: 无法为事务 JAVA MAVEN SPRING 打开 Hibernate 会话 - Could not open Hibernate Session for transaction JAVA MAVEN SPRING Spring Hibernate - 无法为当前线程获取事务同步会话 - Spring Hibernate - Could not obtain transaction-synchronized Session for current thread Spring和Hibernate-无法获得当前线程的事务同步会话 - Spring and Hibernate - Could not obtain transaction-synchronized Session for current thread 无法初始化代理-没有会话(春季休眠一对一) - could not initialize proxy - no Session (Spring-Hibernate-one to one)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM