Transactions using spring framework
1 posts in topic
Flat View  Flat View

Posted By:   Biju_Nair
Posted On:   Friday, August 20, 2004 02:42 AM


I am trying to use declarative transaction using spring frame work.

I am facing a problem like eventhough some errors are coming the transaction is not rolling back.

i feel my perticular method in dao class is not getting involved in the transaction.

I am trying to start the transaction from my buisiness class from where i am calling the dao method.

can any body suggest me what are all the setting i should make to a method involved in a transaction?

Thanking u


Re: Transactions using spring framework

Posted By:   Kenil_Baxi  
Posted On:   Thursday, August 26, 2004 01:26 PM


Use DataSourceTransactionManager for transaction. Following is the example code:

DataSourceTransactionManager dsTM = new DataSourceTransactionManager(dataSource);

TransactionTemplate tt = new TransactionTemplate(dsTM);

tt.execute(new TransactionCallbackWithoutResult() {
protected void doInTransactionWithoutResult(TransactionStatus status)
//update or delete or insert operation 1
//update or delete insert operation 2

By using following code if second update call will fail then it will rollback the first update.


About | Sitemap | Contact