Hibernate会在尝试插入并失败flush()

时间:2018-12-07 09:10:57

标签: spring hibernate oracle12c ojdbc

当我要保存一个具有复合ID的对象时,给出了以下错误。 这是在oracle sql 12c服务器中发生的,但在11g服务器中没有发生。

  

Blockquote   org.hibernate.StaleStateException:批处理更新从更新[0]返回了意外的行数;实际行数:0;预期:1       在org.hibernate.jdbc.Expectations $ BasicExpectation.checkBatched(Expectations.java:85)       在org.hibernate.jdbc.Expectations $ BasicExpectation.verifyOutcome(Expectations.java:70)       在org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:90)       在org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)       在org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)       在org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:114)       在org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:109)       在org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:244)       在org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2525)       在org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2478)       在org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2805)       在org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:114)       在org.hibernate.engine.ActionQueue.execute(ActionQueue.java:268)       在org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:260)       在org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:180)       在org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)       在org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)       在org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)   ..   ..

当我检查跟踪时,遇到休眠状态会触发插入查询,然后会触发具有相同值的相同记录的更新查询。

我将组合键定义如下。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"><hibernate-mapping package="package.of.the.class">
    <class name="ClassName"  table="TABLE_NAME">
        <composite-id>
            <key-property name="variable1_string" column="col1" />
            <key-property name="variable2_string" column="col2" />
            <key-property name="variable3_date" column="col3" />
            <key-property name="variable4_date" column="col4" />
            <key-property name="variable5_string" column="col5" />
        </composite-id>

        other properties...

    </class>

</hibernate-mapping>

当调试器保存记录时,我检查了值,但是ID列没有重复的值。

库版本如下。

  • 休眠3.5
  • ojdbc6
  • spring-aop 4.3.1
  • spring-core 4.3.1
  • spring-jdbc 4.3.1
  • spring-orm 3.2.2
  • Oracle sql server 12c

请,有人告诉我出了什么问题吗?

0 个答案:

没有答案