简体   繁体   中英

On closing transaction, Oracle DB Link doesn't update the database

I have some insert operations under the database "A". Next, I have an operation with the database "A" which connect with the database "B" using Oracle DB Link to update into the second one. When the method execution finish, all the operations over the database "A" are persisted, but the operation over the database "B" doesn't exist.

I'm using Spring 3.2.3.RELEASE and MyBatis 3.2.3

My applicationContext.xml:

<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
</bean>

<tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
        <tx:method name="get*" read-only="true" />
        <tx:method name="*" />
    </tx:attributes>
</tx:advice>

<aop:config proxy-target-class="false">
    <aop:pointcut id="businessEbOperation" expression="bean(*BO)" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="businessEbOperation" />
</aop:config>

<!-- define the SqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="typeAliasesPackage" value="com.foo.core.entities" />
    <property name="configLocation" value="classpath:mybatis-config.xml" />
</bean>

<!-- Oracle 10g DataSource -->
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName">
        <value>java:/OracleDS</value>
    </property>
</bean>

Thanks in advance!

Initially, I thought that the problem was the database configuration, but when I revised the query in MyBatis, I detected the tag select and not the tag update :

<update id="cancelPackage" statementType="CALLABLE">
    {call pa_packages.cancel_cellular_packages(
    #{PKT_ID, mode=IN, jdbcType=VARCHAR}
    , #{CAN_DATE, mode=IN, jdbcType=DATE, javaType=java.util.Date}
    , #{CELLULAR, mode=IN, jdbcType=VARCHAR}
    ...)}
</update>

As a conclusion, the use of DB Links is transparent and it's handled by the database. When the function ends, all the modifications are committed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM