Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot use ContextTransactionalCallable with TransactionProvider

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?

like image 737
PrEto Avatar asked Sep 16 '18 10:09

PrEto


1 Answers

Using out of the box features:

You have to pick one of the two approaches:

  • Spring's declarative transaction management through annotations
  • jOOQ's programmatic transaction management through its API

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.

Using custom TransactionProvider implementations

You 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.

like image 65
Lukas Eder Avatar answered Sep 30 '22 05:09

Lukas Eder