ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kaushik123 <ev.kaus...@gmail.com>
Subject How to roll back a transaction?
Date Mon, 12 May 2008 16:45:03 GMT

Hi ,
    I am using IBATIS with Spring framework.I am not able to do rollback in
case if there are any exceptions for a transaction.
I am using the following java code  

import org.springframework.jdbc.datasource.DataSourceTransactionManager;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import org.springframework.transaction.TransactionDefinition;

import org.springframework.transaction.TransactionStatus;

import org.springframework.transaction.support.DefaultTransactionDefinition;

DefaultTransactionDefinition def;

      TransactionStatus status  ;

     

        private DataSourceTransactionManager transactionManager;

def = new DefaultTransactionDefinition();

     
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);                 

      status = transactionManager.getTransaction(def);

 

if there are any exception ,

transactionManager.rollback(status)

else

transactionManager.commit(status)

 

 

my SQlmapconfig.xml

<sqlMapConfig>

      <settings enhancementEnabled="true" maxTransactions="20"

            maxRequests="32" maxSessions="10" />

      <transactionManager type="JDBC" commitRequired="true">

      <dataSource type="DBCP">

      <property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver" />

     <property name="url" value="xyz " />

     <property name="username" value="xx" />

     <property name="password" value="xx" />

    <property name="defaultAutoCommit" value="false" />

      </dataSource>    

      </transactionManager>        

      <sqlMap resource="ADbution.xml" />

</sqlMapConfig>

 

Let me know if I have to do any changes
-- 
View this message in context: http://www.nabble.com/How-to-roll-back-a-transaction--tp17189869p17189869.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Mime
View raw message