Hibernate只在批处理中失败

时间:2014-06-12 22:44:44

标签: java hibernate

只有在使用多个事务的批处理插入Sybase表时,才会出现唯一性约束错误。 当我一次做一个,它很好。有什么想法吗?

org.hibernate.exception.GenericJDBCException: could not insert collection: [Product.CustomerList#component[ProductId,ProductVersion]{ProductVersion=0, ProductId=XBN20140603}]
        at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1183)
        at org.hibernate.action.CollectionRecreateAction.execute(CollectionRecreateAction.java:26)
        at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:145)
        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 org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:343)
        at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
Caused by: java.sql.SQLException: columns ProductId, ProductVersion, CustomerLevel are not unique
        at org.sqlite.DB.throwex(DB.java:288)
        at org.sqlite.DB.executeBatch(DB.java:236)
        at org.sqlite.PrepStmt.executeBatch(PrepStmt.java:82)
        at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
        at org.hibernate.jdbc.BatchingBatcher.addToBatch(BatchingBatcher.java:34)
        at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1146)

0 个答案:

没有答案