I have an error, which I can't solve.
I am using Spring and JOOQ.
Error occurs here:
@Transactional
public UUID create(List<User> users) {
UUID uuid = UUID.randomUUID();
dslContext.transaction(() -> {
dslContext
.insertInto(APPLE, APPLE.APPLE_ID, APPLE.TITLE)
.values(uuid, uuid.toString())
.execute();
users.forEach(user -> {
dslContext
.insertInto(APPLE_MEMBERS, APPLE_MEMBERS.APPLE_ID, APPLE_MEMBERS.USER_ID)
.values(uuid, user.getUserId())
.execute();
});
});
return uuid;
}
Error:
org.jooq.exception.ConfigurationException: Cannot use ContextTransactionalCallable with TransactionProvider of type class org.springframework.boot.autoconfigure.jooq.SpringTransactionProvider
Maybe someone had same error or has idea how to solve this error?
You have to pick one of the two approaches:
Out of the box, they cannot be combined. In your particular case, I don't see why you would want to do it. The nested, programmatic transaction has the exact same scope as the outer, declarative transaction. It is redundant.
TransactionProvider
implementationsYou could write your own TransactionProvider
that is able to communicate with Spring's transaction management and allows for embedding nested transactions in @Transactional
annotated methods, but I generally advise against it. Pick one of the two approaches.