I know that unchecked Exceptions (RuntimeExceptions) will usually cause a rollack of your transaction but what happens if you catch that exception in the same mothod? I want the rollback the whole transaction when errorOccurred is true. But I wonder if catching Exception will swallow the RuntimeException hence causing the transaction to NOT rollback? Does this code still rollback the transaction?
public static void main(String[] args) {
try {
// boring stuff...
if(errorOccurred)
throw new RuntimeException("RuntimeException is thrown.");
} catch (Exception e) {
System.out.println("RuntimeException cought. Does is still rollback transaction?");
}
}
manualexception handling you should rollback yourself. - NiVeR