I thought that RuntimeExceptions in a @Transaction lead to a revert and checked exceptions not.
For example I have two classes:
A:
@POST
@Path( DO_SOMETHING )
@Consumes( MediaType.APPLICATION_JSON )
@Produces( { MediaType.APPLICATION_JSON } )
@Authenticated
public RestResponse doSomething( SetttingsDTO settings ) {
Response eok = new Response();
try {
b.callMe( settings );
eok.setResponse( "Successfull", null );
} catch ( Exception ex ) {
log.error( ex.getMessage() );
eok.setResponse( ex );
}
return eok;
}
B class:
@Transactional
public void callMe( SetttingsDTO settings ) throws Exception {
/*
Here we do some things in the database
*/
throw new IOException("Test");
}
In my understanding because the IOException is thrown and catched in the Class A the database should not return the database-changes. But in real the database does revert. Although the exception is catched my database-changes are written in the database.
Can someone please explain why?