Back Forum Reply New

Newbie to Spring. need help

Hi
I have multiple methods making some JDBC calls to database. i want to make all these methods as a single transaction. means if any method fails in its JDBC transaction, prevously executed JDBCtransactions should roll back. need ur advice to start up.
Thanks
-Chandra K

You'll want to make the method which makes those multiple calls tranactional.  Check out the Spring reference manual on transactions the different options.

@Transactional(CustomException.class)
public insertData(SomeDataTO dataTO){
try
{
callMethod1(dataTO,......);
callMethod2(dataTO, ....);
}catch(Exception e){
ExceptionUtils.printStackTrace();
}
}

callMethod2 throws exception of type CustomException. for this type entire transaction has to be rolled back

Config files:

defined both PlatformTransactionManager class bean type and annotation is also mentioned. Any advice is appreciated.
¥
Back Forum Reply New