`
folicas
  • 浏览: 6092 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

Could not synchronize database state with session

阅读更多
ERROR - Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:114)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:109)
at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:244)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2242)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2678)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:366)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:655)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:732)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:701)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:321)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:116)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy15.commonContactAdd(Unknown Source)
at com.jinying.action.CommonContactEditAction.commonContactAdd(CommonContactEditAction.java:47)
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 com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.sql.BatchUpdateException: ORA-00001: unique constraint (JYDEVICE.COMMONCONTACTID) violated

at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:342)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10656)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
... 95 more

产生原因:主要是hibernate报出下列异常,为主键冲突异常。
可以先查看hibernate配置文件中的主键策略是否为sequence,如果是,再查看数据库中原始数据是否存在该sequence的nextVal的数据, 一般把初始值设大点就行了!
如果存在只需要修改sequence的下一个值或者修改原始数据,该异常就可以解决了。
分享到:
评论

相关推荐

    delphi vcl线程同步synchronize

    Synchronize方法是Delphi中用于在主线程和工作线程之间进行通信的关键工具,确保对用户界面(UI)的操作是安全的。本文将深入探讨Delphi VCL线程同步以及Synchronize方法的工作原理、使用场景和最佳实践。 ### 1. ...

    Database Comparer VCL v 5.0

    These components allow you to compare and synchronize SQL database objects and table records for many popular databases. You can view all the differences between databases and execute an automatically...

    Oracle rac 10g for linux vmware安装笔记

    一、安装主机网卡 二、安装虚拟机 三、同步主机和linux系统时间(Synchronize Guest OS time with Host OS) 四、配置oracle用户

    Clever Database Comparer v6.2.0.733 - Full Sources for CBuilder/Delphi〖D5~XE8〗

    Database Comparer helps to compare, synchronize and update databases structure. You can compare one database with another database or database with SQL/DDL script or even two SQL/DDL scripts!

    Synchronize Your System Time with a Network Time Protocol (N

    标题中的“Synchronize Your System Time with a Network Time Protocol (NTP) Server”指的是通过网络时间协议(Network Time Protocol)同步计算机系统时间的过程。NTP是一种用于在互联网上同步计算机时间的协议,...

    DevExpress VCL v2012 vol 1.6源码、例子、帮助-part2

    Q435475 - Tabular and Layout Views - The View does not synchronize edit value changes with the data controller in the OnEditChanged event handler if DataController.Options includes dcoImmediatePost, ...

    java synchronize 线程同步

    Java中的`synchronized`关键字是用于实现线程同步的关键机制,主要目的是解决多线程环境下的数据安全问题。当多个线程访问共享资源时,如果没有适当的同步控制,可能会导致数据不一致或者竞态条件等问题。...

    Synchronize It 3.5文件夹同步器 简体中文界面

    Synchronize It!还有其他特点如下: 1.可以自订许多的项目,包括过滤器、专案、颜色等等。 2.可以进行多种同步任务独立保存和点用,也可组合多个任务一次同步搞定。 3.支持压缩文件的同步。 4.内建二进位文件的比较...

    CALL RFC synchronize and asychronize Examples

    以下是关于"CALL RFC synchronize and asychronize Examples"的详细解释。 **同步调用 (Synchronize Call)** 同步调用是立即执行并等待结果返回的方式。在提供的示例`SAPBC415_RFCSYNC_S1`中,我们看到如何通过`...

    FTP_synchronize_0_9_6_1_dll

    FTP_synchronize_0_9_6_1_dll 是一个针对Notepad++文本编辑器的FTP同步插件,主要用于帮助用户实现本地代码与远程服务器之间的文件同步。Notepad++是一款非常流行的开源文本编辑器,尤其受到程序员和Web开发者的喜爱...

    Multithreading with C# Cookbook(PACKT,2ed,2016)

    Work with raw threads, synchronize threads, and coordinate their work Develop your own asynchronous API with Task Parallel Library Work effectively with a thread pool Scale up your server ...

    DevArt dbForge Studio for SQL Server Enterprise Edition 5.0.337

    Generate scheduled database scripts with data through command line Boost SQL coding in a convenient scripting environment Analyze and improve T-SQL code quality Design tables and rebuild them without ...

    Java synchronize线程安全测试

    Java中synchronize关键字的使用与线程安全测试 Java语言中,synchronize关键字是一个非常重要的概念,它主要用于解决线程安全问题。在多线程编程中,经常会出现线程安全问题,因为多个线程可能会访问同一个共享资源...

    Java synchronize底层实现原理及优化

    Java synchronize 底层实现原理及优化 在 Java 中,synchronize 是一种锁机制,用于控制并发冲突,避免多个线程同时访问同一个资源。synchronize 底层实现原理及优化是 Java 并发编程中一个重要的概念,本文将详细...

    vnc.rar_Computers_file synchronize

    simple configure file to synchronize the connection between two computers (using vnc)

    Devart dbForge Studio for MySQL Professional Edition v7.1.13

    dbForge Studio also provides utilities to compare, synchronize, and backup MySQL databases with scheduling, and gives possibility to analyze and report table data. Over 15,000 users rely on dbForge ...

    synchronize底层实现原理

    synchronize底层实现原理 Java文件想要看字节码通常使用 javap 命令将java的class文件反汇编,具体操作步骤如下: 1. 先写好一个SynchronizedTest.java文件(下面贴出) 2. 在java文件的目录下,使用命令 javac ...

    Java之Synchronize学习

    Synchronize的几种实现 Synchronize有三种实现。 同步方法,修饰实例方法,作用于当前实例加锁,进入同步代码前要获得当前实例的锁 静态方法,作用于当前类对象加锁,进入同步代码前要获得当前类对象的锁 修饰代码块...

    4-Synchronize Robots_高清 720P.mp4

    4-Synchronize Robots_高清 720P.mp4

    Synchronize和ReentrantLock区别.png

    Synchronize(同步锁)和ReentrantLock(可重入锁)都是Java中的常用锁,都是用来保证线程安全的。两者都是同步锁,且都是阻塞同步。阻塞同步:当一个线程获取锁后,其他线程只能等待(进入阻塞态),等待获取锁的...

Global site tag (gtag.js) - Google Analytics