By arunraj
For transaction management with Spring 2.0 refer the article Spring AOP
With respect to Spring 3.0, Transaction management can be done in a much simpler way.
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<description>
Transaction manager for a single JDBC DataSource
</description>
<property name="dataSource" ref="dataSource"/>
</bean>
Add the @Transactional annotation at the top of each method which needs to be executed under the transaction.
@Transactional
public void execute()
{
/*
* For example:
* Add code to insert into table T1
* Add code to update rows in table T2
* If insertion in to table T1 fails , then updation in T2 will not happen
*/
}
public void execute()
{
/*
* For example:
* Add code to insert into table T1
* Add code to update rows in table T2
* If insertion in to table T1 fails , then updation in T2 will not happen
*/
}
Technology: