I've written a simple web app, which I based off of the sample Spring/iBatis JPetstore application.
When I use a DataSourceTransactionManager, everything works as expected. But when I use JtaTransactionManager, it seems that autocommit is enabled. Individual SQL statements are being committed before the business transaction is completed.
Any ideas what's causing this? Not sure if this is relevant, but I'm running the app in the embedded OC4J container that gets launched from Oracle JDeveloper 10g.
Relevant context configuration files are shown below.
Thanks in advance !!
Steve
------------------------------------------------------------------------------------
dataAccessContext-local.xml (uses DataSourceTransactionManager)
------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- ========= RESOURCE DEFINITIONS ========= -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName"><value>${jdbc.driverClassNa me}</value></property>
<property name="url"><value>${jdbc.url}</value></property>
<property name="username"><value>${jdbc.username}</value></property>
<property name="password"><value>${jdbc.password}</value></property>
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSou rceTransactionManager">
<property name="dataSource"><ref local="dataSource"/></property>
</bean>
<!-- SqlMap setup for iBATIS Database Layer -->
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClient FactoryBean">
<property name="configLocation"><value>WEB-INF/sql-map-config.xml</value></property>
</bean>
<!-- ==== DAO DEFINITIONS: IBATIS IMPLEMENTATIONS ==== -->
<bean id="accountingPeriodDao" class="nz.ac.otago.its.chargeadmin.dao.ibatis.SqlM apAccountingPeriodDao">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="sqlMapClient"><ref local="sqlMapClient"/></property>
</bean>
<bean id="chargeDao" class="nz.ac.otago.its.chargeadmin.dao.ibatis.SqlM apChargeDao">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="sqlMapClient"><ref local="sqlMapClient"/></property>
</bean>
[etc]
</beans>
------------------------------------------------------------------------------------
dataAccessContext-jta.xml (uses JtaTransactionManager)
------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- ========= RESOURCE DEFINITIONS ============ -->
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryB ean">
<property name="jndiName"><value>jdbc/itsdevPooledDS</value></property>
</bean>
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTran sactionManager"/>
<!-- SqlMap setup for iBATIS Database Layer -->
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClient FactoryBean">
<property name="configLocation"><value>WEB-INF/sql-map-config.xml</value></property>
</bean>
<!-- ==== DAO DEFINITIONS: IBATIS IMPLEMENTATIONS ==== -->
<bean id="accountingPeriodDao" class="nz.ac.otago.its.chargeadmin.dao.ibatis.SqlM apAccountingPeriodDao">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="sqlMapClient"><ref local="sqlMapClient"/></property>
</bean>
<bean id="chargeDao" class="nz.ac.otago.its.chargeadmin.dao.ibatis.SqlM apChargeDao">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="sqlMapClient"><ref local="sqlMapClient"/></property>
</bean>
[etc]
</beans>
-----------------------------------------------------------------------------
applicationContext.xml
-----------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- ========== GENERAL DEFINITIONS ========== -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>WEB-INF/mail.properties</value>
<value>WEB-INF/jdbc.properties</value>
</list>
</property>
</bean>
<!-- ======== BUSINESS OBJECT DEFINITIONS ======= -->
<bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean"
abstract="true">
<property name="transactionManager"><ref bean="transactionManager"/></property>
<property name="transactionAttributes">
<props>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
<!-- primary business object -->
<bean id="chargeAdmin" parent="baseTransactionProxy">
<property name="target">
<bean class="nz.ac.otago.its.chargeadmin.domain.logic.Ch argeAdminImpl">
<property name="accountingPeriodDao"><ref bean="accountingPeriodDao"/></property>
<property name="chargeDao"><ref bean="chargeDao"/></property>
[etc]
</bean>
</property>
</bean>
</beans>


Reply With Quote