i am trying to learn spring transaction. i am using jdbcTemplate for setting up connection but @Transactional(rollbackFor=Exception.class) does not seem working as it is not rolling back the data.
to give an overview i have written two methods. one method will reduce some amount from one row and other method will increase the amount in other row. i am calling both the methods from one single method and annotated that single method with @Transactional(rollbackFor=Exception.class) as mentioned below.
i am already having accountDao object so please don't worry about that.
now i am calling creditInToAccount method first and debitFromFromAccount next to it. in my debitFromFromAccount method i am throwing an Exception which should actually rollback the result of query executed in creditInToAccount but rolling back of creditInToAccount is not happening.
i check javaranch for the same and came across below mentioned thread
http://www.coderanch.com/t/572768/Spring/Rollback-not-working-Transactional#2605624 but in this link it is mentioned to set autocommit as false but i dont know how to do the same when using jdbcTemplate.
below is the snippet of xml that i am using for configuration
thanks for the reply. your doubt was right. my TransferService class(in which transferMoney() method was there) was not under control of Spring. i have defined TransferService class as @Service and now its working