Hi Denis,

Thanks for your question. The jOOQ transaction API was mainly defined to
work in simple, JDBC-style situations where there are not Java EE style
propagations and other transaction "flags". While it is currently possible
to bind the jOOQ TransactionProvider to Spring TX (or to JTA), it is not so
easy to pass the propagation flag to it, out of the box.

If you're using the current transaction API in jOOQ:
DSLContext.transaction( () -> { ... } ), then you cannot use the
@Transactional annotations. The two APIs are mutually exclusive. jOOQ uses
a programmatic API, Spring supports both programmatic and declarative,
annotation-based APIs. You can pass the propagation to your Spring
DataSourceTransactionManager, which is inside of the
SpringTransactionProvider. There is a pending feature request that will
allow for that to work out of the box:
https://github.com/jOOQ/jOOQ/issues/4836

Currently, this is not yet documented, but I'm happy to help you on the way.

I hope this answers your question thus far. If not, just let me know.
Best Regards,
Lukas

2016-06-09 18:24 GMT+03:00 Denis Miorandi <[email protected]>:

> Hi,
>       I've got a spring4+jooq application, based on
> jOOQ-spring-boot-example/
> I would like to use *PROPAGATION_REQUIRES_NEW* in a method called inside
> another transactional (to obtain and indipendent transaction) method
> marked as *PROPAGATION_REQUIRES* that is default.
> Should it work in your example project?
> It seems to me that it doens't work cause my transactionProvider define
> "statically" the default behavior as PROPAGATION_REQUIRES
> and when it change on @Transactional annotation is doesn't take effect. Is
> it possible?
>
> This is my provider.
>
> public class SpringTransactionProvider implements TransactionProvider {
>
>       private static final JooqLogger log = 
> JooqLogger.getLogger(SpringTransactionProvider.class);
>
>       @Autowired DataSourceTransactionManager txMgr;
>
>       @Override
>       public void begin(TransactionContext ctx) {
>               log.info("Begin transaction");
>
>               // This TransactionProvider behaves like jOOQ's 
> DefaultTransactionProvider,
>               // which supports nested transactions using Savepoints
>               // but use PROPAGATION_REQUIRED AS DEFAULT
>               TransactionStatus tx = txMgr.getTransaction(new 
> DefaultTransactionDefinition(PROPAGATION_REQUIRED));
>               ctx.transaction(new SpringTransaction(tx));
>       }
>
>       @Override
>       public void commit(TransactionContext ctx) {
>               log.info("commit transaction");
>               txMgr.commit(((SpringTransaction) ctx.transaction()).tx);
>       }
>
>       @Override
>       public void rollback(TransactionContext ctx) {
>               log.info("rollback transaction");
>               txMgr.rollback(((SpringTransaction) ctx.transaction()).tx);
>       }}
>
> --
> You received this message because you are subscribed to the Google Groups
> "jOOQ User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to