I use jOOQ 3.8 and Spring Boot 1.4.1. I see that jOOQ uses a mechanism to guarantee the handling of transactions.
If I define a method annotated as transactional and inside a execute two insert, are they executed in the same transaction, e.g.
@Transactional(propagation = Propagation.MANDATORY)
public doInsert(){
DSL.using(configuration).insertInto(...);
DSL.using(configuration).insertInto(...);
}
will all the executed insert rollback in case of exception? Will they be executed in one transaction?
Or, should I do as follows:
public doInsert(){
create.transaction(configuration -> {
DSL.using(configuration).insertInto(...);
DSL.using(configuration).insertInto(...);
});
}
And what happens if I use the annotation and the jOOQ transaction as follows:
@Transactional(propagation = Propagation.MANDATORY)
public doInsert(){
create.transaction(configuration -> {
// Wrap configuration in a new DSLContext:
DSL.using(configuration).insertInto(...);
DSL.using(configuration).insertInto(...);
});
throw new RuntimeException(":)");
}
Will the changes in the transaction be committed regardless of the exception? (I would expect it)