I clearly need some help about transaction roll back. I'm working on a Spring/JPA/Hibernate application.
For me, RuntimeException
even if they are catched, are rolling back the transaction. I deduce this with some tests (that I can't put here unfortunatly as I don't have them anymore) and readings.
But I'm experiencing another behaviour with the following code :
public class Service implements IService {
@Transactional
public void test()
{
// ...
try {
throw new RuntimeException();
} catch (RuntimeException re) {
}
foo.setBar(barValue);
this.fooDao.save(foo);
}
}
After executing this from the controller, the change on bar
parameter is present in my database which mean that the transaction has not been rollbacked.
Now the question
Does a catched runtimeException lead to a rollback or am I wrong ?