org.hibernate.StaleObjectStateException, возникающий в session.flush(); после вызова saveOrUpdate в реализации HibernateDaoSupport

Я получаю ниже исключение в коде ниже:

   session = getHibernateSession();
   transxn = session.beginTransaction();
   session.saveOrUpdate(inputReqDTO);
   getHibernateTemplate().flush(); /* <-- Exception is caused at here*/

Журнал ошибок:

org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.patipukurbottleplant.employeespayroll.dao.hibernate.mappingclasses.objects.PartyService#Party id: 10000024 AND Service Pref Reg id: 256]

Таблица БД SERVICE_REGISTRATION_ASSOCIATION имеет первичный ключ для своих столбцов PRTYID & SRVC_REG_ID

Мой картограф hbm.xml выглядит так:

<?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
    <!-- Generated Mar 18, 2012 10:32:26 PM by Hibernate Tools 3.2.2.GA -->
    <hibernate-mapping>
        <class name="org.patipukurbottleplant.employeespayroll.dao.hibernate.mappingclasses.objects.PartyService" table="SERVICE_REGISTRATION_ASSOCIATION" >
            <composite-id name="id" class="org.patipukurbottleplant.employeespayroll.dao.hibernate.mappingclasses.objects.PartyServiceId">
                <key-property name="partyId" type="long">
                    <column name="PRTYID" precision="10" scale="0" />
                </key-property>
                <key-property name="ServicePreferenceId" type="long">
                    <column name="SRVC_REG_ID" precision="15" scale="0" />
                </key-property>
            </composite-id>
            <version name="version" type="int" column="VERSION" insert="true" />

            <many-to-one name="ServicePreference" class="org.patipukurbottleplant.employeespayroll.dao.hibernate.mappingclasses.objects.ServicePreference" update="false" insert="false" fetch="select">
                <column name="SRVC_REG_ID" precision="15" scale="0" not-null="true" />
            </many-to-one>
            <many-to-one name="prtyRole" class="org.patipukurbottleplant.employeespayroll.dao.hibernate.mappingclasses.objects.PrtyRole" update="false" insert="false" fetch="select">
                <column name="PRTYID" precision="10" scale="0" not-null="true" />
            </many-to-one>
            <many-to-one name="GeneralMaster" class="org.patipukurbottleplant.employeespayroll.dao.hibernate.mappingclasses.objects.GeneralMaster" fetch="select">
                <column name="STATUS_CODE" length="20" />
            </many-to-one>
            <property name="alternateCriteriaName" type="string">
                <column name="ALTERNATE_CRITERIA_NAME" length="200" />
            </property>
            <property name="visible" type="string">
                <column name="VISIBLE" length="200" />
            </property>
            <set name="runCounts" inverse="true" lazy="false" cascade="all">
                <key>
                    <column name="PRTYID" precision="10" scale="0" not-null="true" />
                    <column name="SRVC_REG_ID" precision="15" scale="0" not-null="true" />
                </key>
                <one-to-many class="org.patipukurbottleplant.employeespayroll.dao.hibernate.mappingclasses.objects.ServiceRunCount" />
            </set>
            <set name="userServiceRunCount" inverse="true" lazy="false" cascade="all">
                <key>
                    <column name="PRTYID" precision="10" scale="0" not-null="true" />
                    <column name="SRVC_REG_ID" precision="15" scale="0" not-null="true" />
                </key>
                <one-to-many class="org.patipukurbottleplant.employeespayroll.dao.hibernate.mappingclasses.objects.UserServiceRunCount" />
            </set>
        </class>


         <class name="org.patipukurbottleplant.employeespayroll.dao.hibernate.mappingclasses.objects.ProductionConfiguration">
                <id name="partyId" type="java.lang.Long">
                    <column name="PRTYID" precision="15" scale="0" />
                </id>
                <property name="serviceId" type="java.lang.Long">
                    <column name="SERVICE_ID" precision="15" scale="0" />
                </property>
                <property name="srvcPrefRegID" type="java.lang.Long">
                    <column name="SRVC_REG_ID" precision="15" scale="0" />
                </property>
        </class>        
    </hibernate-mapping>

Я на самом деле пытался во многих отношениях, как:

<bean class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" id="serviceMgmtTxProxy">
        <property name="transactionManager">
            <ref bean="transactionManager"/>
        </property>
        <property name="target">
            <ref bean="transManagerHelper"/>
        </property>
        <property name="transactionAttributes">
            <props>
                <prop key="*">PROPAGATION_REQUIRED,-Exception</prop>
            </props>
            </property>

      </bean>

а также как PROPAGATION_REQUIRED,ISOLATION_READ_COMMITTED,-Exception, Но это не сработало.

Любое предложение поможет мне, потому что я не получаю никакой надлежащей подсказки, гуглящей и stckflowing. И спасибо, что прочитали этот вопрос.

0 ответов

Другие вопросы по тегам