hibernate ConstraintViolationException解决方案之一

hibernate报出下列异常,为主键冲突异常。可以先查看hibernate配置文件中的主键策略是否为sequence,如果是,再查看数据库中原始数据是否存在该sequence的nextVal的数据,
如果存在只需要修改sequence的下一个值或者修改原始数据,该异常就可以解决了。
org.hibernate.event.def.AbstractFlushingEventListener  - 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:71)
> at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
> at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
> at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
> at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
> 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:1000)
> at com.citi.cmb.gce.admin.db.daoimpl.InterfaceDaoImpl.insertInterfaceDetails(InterfaceDaoImpl.java:333)
> at com.citi.cmb.gce.admin.pojo.InterfaceService.insertInterfaceDetails(InterfaceService.java:118)
> at com.citi.cmb.gce.admin.ejbs.InterfaceMDBBean.onMessage(InterfaceMDBBean.java:62)
> at com.ibm.ejs.container.MessageEndpointHandler.invokeMdbMethod(MessageEndpointHandler.java:1014)
> at com.ibm.ejs.container.MessageEndpointHandler.invoke(MessageEndpointHandler.java:747)
> at $Proxy8.onMessage(Unknown Source)
> at com.ibm.ws.sib.api.jmsra.impl.JmsJcaEndpointInvokerImpl.invokeEndpoint(JmsJcaEndpointInvokerImpl.java:201)
> at com.ibm.ws.sib.ra.inbound.impl.SibRaDispatcher.dispatch(SibRaDispatcher.java:768)
> at com.ibm.ws.sib.ra.inbound.impl.SibRaSingleProcessListener$SibRaWork.run(SibRaSingleProcessListener.java:584)
> at com.ibm.ejs.j2c.work.WorkProxy.run(WorkProxy.java:419)
> at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1473)
> Caused by: java.sql.BatchUpdateException: ORA-00001: unique constraint (ADMIN.INTERFACE_PK) violated
> at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:367)
> at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:8739)
> at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecuteBatch(WSJdbcPreparedStatement.java:808)
> at com.ibm.ws.rsadapter.jdbc.WSJdbcStatement.executeBatch(WSJdbcStatement.java:612)
> at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
> at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)

你可能感兴趣的:(java,oracle,Hibernate,jdbc,IBM)