当前位置: 代码迷 >> Java Web开发 >> 违反唯一约束条件解决方案
  详细解决方案

违反唯一约束条件解决方案

热度:4149   发布时间:2013-02-25 21:12:28.0
违反唯一约束条件
发布时没有报错,进去后点一些表单就会报错,但是多点几次也能正常显示。数据库是导入的最新数据,root也是对应的最新的。 

Caused by: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:254)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1001)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:339)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:54)
at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:456)
... 127 more
Caused by: java.sql.BatchUpdateException: ORA-00001: 违反唯一约束条件 (HC_CIMP.PRIMARY_111)

at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:629)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:9409)
at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:211)
at com.jolbox.bonecp.StatementHandle.executeBatch(StatementHandle.java:446)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:247)
... 136 more


------解决方案--------------------------------------------------------
看你点那些表单出错啊,找问题在哪里
------解决方案--------------------------------------------------------
嗯,不是你的项目错了,是数据的问题。

看报告的错误,是说违反唯一约束条件,所以看看数据的问题。看着像是主键冲突了。

看看你要提交的数据,跟你导入到数据库中的数据是不是有主键冲突的。
------解决方案--------------------------------------------------------
你是不是批量更新?批量更新的时候是不是把主键都改成相同的了?改成相同的比如会违反唯一约束了
  相关解决方案