问题描述
11:32:04,424ERRORAbstractFlushingEventListener:301-Couldnotsynchronizedatabasestatewithsessionorg.hibernate.exception.ConstraintViolationException:couldnotinsert:[com.edabao.member.business.bargainlog.model.BargainLog]atorg.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)atorg.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)atorg.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2267)atorg.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2660)atorg.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:56)atorg.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)atorg.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)atorg.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)atorg.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)atorg.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)atorg.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)atcom.edabao.member.business.bargainlog.service.BargainLogServiceBase.insert(BargainLogServiceBase.java:36)atcom.edabao.member.business.bargainlog.service.BargainLogService.insertMember(BargainLogService.java:44)atcom.edabao.member.business.bargainlog.service.BargainLogService$$FastClassByCGLIB$$d007a35b.invoke(<generated>)atnet.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)atorg.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:692)atorg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)atorg.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)atorg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)atorg.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)atorg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)atorg.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:625)atcom.edabao.member.business.bargainlog.service.BargainLogService$$EnhancerByCGLIB$$d0516b60.insertMember(<generated>)atcom.edabao.member.business.bargainlog.action.BargainLogAction.member(BargainLogAction.java:25)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)atjava.lang.reflect.Method.invoke(Method.java:585)atcom.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)atcom.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)atcom.framework.web.interceptor.ExceptionInterceptor.intercept(ExceptionInterceptor.java:27)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)atcom.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)atorg.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)atcom.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)atcom.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)atcom.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atorg.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atorg.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atorg.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atorg.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)atcom.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atorg.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.framework.web.interceptor.LogInterceptor.intercept(LogInterceptor.java:50)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.framework.web.interceptor.UserInterceptor.intercept(UserInterceptor.java:102)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atorg.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)atorg.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)atorg.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)atorg.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter
解决方案
解决方案二:
配置文件出错了
解决方案三:
尽量将源码、异常一起贴上!!!org.hibernate.exception.ConstraintViolationException:couldnotinsert:[com.edabao.member.business.bargainlog.model.BargainLog]不能insert你上一记录没有提交(commit);外键与主键值不等
解决方案四:
Couldnotsynchronizedatabasestatewithsession这个异常引发的原因就很明显了,当企图更新一个不存在的id实体时,便发生了这样的异常。
解决方案五:
是不是同时保存了多张表例如表2在保存对象数据时有一部分要保存的数据是表一对象的,但是表一这个对象还没保存不知道说明白了没?
解决方案六:
org.hibernate.exception.ConstraintViolationException:couldnotinsert:[com.edabao.member.business.bargainlog.model.BargainLog]你插入的时候报错了,看看是不是插入的代码那里写的列不对称