-
Nov 14th, 2011, 09:49 PM
#1
DBUnit/Spring transaction not rolling back when using OracleDataSource
I'm trying to use DBUnit to insert spatial data into an oracle database and then roll it back. In order to insert the spatial data, I must use Oracle10DataTypeFactory which pulls in the other DBUnit Oracle extensions for spatial data types. Internally, they will do a cast to OraclePreparedStatement. In order to get an OraclePreparedStatement I use an OracleDataSource. So when I use the following Spring configuration:
<bean id="testDataSource" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close" scope="singleton">
<property name="URL" value="${database.url}"/>
<property name="user" value="${user}"/>
<property name="password" value="${password}"/>
<property name="implicitCachingEnabled" value="false" />
<property name="explicitCachingEnabled" value="false" />
<property name="connectionCachingEnabled" value="false" />
</bean>
The inserts never roll back. I know it is associated with the OracleDataSource from the following testing. Insert a row into a table that does not require spatial data. Use the following configuration:
<bean id="testDataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
<property name="url" value="${database.url}"/>
<property name="username" value="${user}/>
<property name="password" value="${password}"/>
</bean>
Everything works fine and the insert is rolled back at test completion. Perform the same exact test with the OracleDataSource as shown previous, forget it, nothing is rolled back. I've looked at autocommit being set to true, but unfortunately Oracle doesn't provide a method for setting on the OracelDataSource, at least not what I could find. So in my test setup I explicitly set it to false with the following:
connection = DataSourceUtils.getConnection(dataSource);
connection.setAutoCommit(false);
I also make sure to set transaction definition to be roll back only. But even all that seems to be ignored.
Any help would be greatly appreciated.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules