I'm using SQLServer
along with Springs JtaTransactionManager
.
Given a method like this:
@Transactional
public void something() {
try (final Connection conn1 = getConnection()) {
//insert/update stuff in database
}
try (final Connection conn2 = getConnection()) {
//insert/update stuff in database
}
}
Will this method actually be transactional? What happens to the changes made when conn1
gets closed, are they commited to the database? What happens if an exception occurs while working with conn2
, can the changes made through a closed connection be rolled back?