Spring transaction not rolling back when using OracleDataSource

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Spring transaction not rolling back when using OracleDataSource

RATERMAN, MARK G (AG-Contractor/1000)
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" />

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}"/>

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);

But even that seems to be ignored.  Any help would be greatly appreciated.


This e-mail message may contain privileged and/or confidential information, and is intended to be received only by persons entitled
to receive such information. If you have received this e-mail in error, please notify the sender immediately. Please delete it and
all attachments from any servers, hard drives or any other media. Other use of this e-mail by you is strictly prohibited.

All e-mails and attachments sent and received are subject to monitoring, reading and archival by Monsanto, including its
subsidiaries. The recipient of this e-mail is solely responsible for checking for the presence of "Viruses" or other "Malware".
Monsanto, along with its subsidiaries, accepts no liability for any damage caused by any such code transmitted by or accompanying
this e-mail or any attachment.

The information contained in this email may be subject to the export control laws and regulations of the United States, potentially
including but not limited to the Export Administration Regulations (EAR) and sanctions regulations issued by the U.S. Department of
Treasury, Office of Foreign Asset Controls (OFAC).  As a recipient of this information you are obligated to comply with all
applicable U.S. export laws and regulations.

RSA(R) Conference 2012
Save $700 by Nov 18
Register now
dbunit-user mailing list
[hidden email]