Thanks Dridi and Eduardo,
The @Transactional annotation was on a handler method of an MVC controller which prevented the transaction from being triggered. This could be related to the dynamic proxy mechanism used by Spring to add the transaction as an advice to the bean. The debug output confirmed that a new connection was returned and no traces on the transaction manager were mentioned
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'sqlSessionFactory'
DEBUG: - ooo Using Connection [oracle.jdbc.driver.T2CConnection@15a3dac]
DEBUG: - ooo Using Connection [oracle.jdbc.driver.T2CConnection@1d3659b]
DEBUG: - ooo Using Connection [oracle.jdbc.driver.T2CConnection@7c6703]
So, I moved the method to a service class as follows
// service method
@Transactional
public String checkUser(String username){
User user = userMapper.getUser(username);
String address = userMapper.getAddress(username);
String telephone = userMapper.getTelephone(username);
return "done";
}
// MVC Controller hander method
@RequestMapping("checkuser")
public String checkUser(@RequestParam("user") String username){
return userService.checkUser(username);
}
Now the transaction got triggered and the same database connection was returned
DEBUG: org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'transactionManager'
DEBUG: - ooo Using Connection [oracle.jdbc.driver.T2CConnection@1bfa3e4]
DEBUG: - ooo Using Connection [oracle.jdbc.driver.T2CConnection@1bfa3e4]
DEBUG: - ooo Using Connection [oracle.jdbc.driver.T2CConnection@1bfa3e4]
No configuration changes were needed.
Thanks