I wouldn't call it "Mix" it's more a delegation process. Spring intercept 
@Transactional annotation and delegate jooq to manage it, but actually I 
don't know how jooq 
can manage "start a new transaction" instead of "use current one" in some 
cases. 

Code is almost identical to the reference one into
https://github.com/jOOQ/jOOQ/tree/master/jOOQ-examples/jOOQ-spring-boot-example

The hot part is the following where is not possible do manage different 
propagation style cause this parameter is not in ctx.
Of course I can implement provider as needed but *I don't know how to have 
@Transactional parameters as input here*, to create transaction in right 
way.

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*         
TransactionStatus tx = txMgr.getTransaction(new 
DefaultTransactionDefinition(PROPAGATION_NESTED));
                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);
        }}






Il giorno venerdì 17 giugno 2016 09:49:52 UTC+2, Lukas Eder ha scritto:
>
> Hi Denis,
>
> 2016-06-15 13:47 GMT+01:00 Denis Miorandi <[email protected] 
> <javascript:>>:
>
>> Hi Lukas,
>>         when you say @Transactional is not supported you mean 
>> @Transactional attributes not supported I suppose.
>>
>
> What I really meant is that the two approaches (Spring / AOP / declarative 
> vs. jOOQ / programmatic) are not really a good match. They shouldn't be 
> mixed, in my opinion. This is independent of jOOQ. You probably wouldn't 
> mix Spring's annotations with Spring's programmatic APIs either.
>
> But perhaps you've found a use-case where mixing is reasonable?
>  
>
>> Actually my SpringTransactionProvider allow use of @Transactional 
>> annotations 
>> ( creating a jooq Transaction in a transparent way) the only missing 
>> things are @Transactional parameters. 
>>
>
> Oh, interesting! Would you be interested in sharing this code? Would be 
> very useful to look into how you did this.
>  
>
>> I suspect  actually due SpringTransactionProvider  is created at spring 
>> boot time it can't intercept specific instance call parameters.
>> Anyway I'm looking forward to #4836.
>> I've added some comments here.
>>
>
> Hmm, not sure. It's a "provider". You can implement it in any way you 
> want. It doesn't have to initialise everything when it is initialised 
> itself...
>

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