Hi!

Has anything happened here? I am trying to find out how I can override the 
default transaction isolation level using the jooq APIs.

Based on what I have read so far this is not possible out of the box, but 
it would seem to be possible to do the following with a small refactoring 
of the SpringTransactionProvider:

try(DSLContext ctx = dbCon.usingCtx()) {
    ctx.transaction(configuration -> {
        TransactionProvider jooqTransactionProvider =  
configuration.transactionProvider();
        DSLContext innerCtx;
        if(jooqTransactionProvider instanceof SpringTransactionProvider) {
            SpringTransactionProvider stp = 
(SpringTransactionProvider)jooqTransactionProvider;
            SpringTransactionProvider localTsp = 
stp.derive(configuration.connectionProvider(), 
TransactionDefinition.ISOLATION_SERIALIZABLE);

            Configuration derivedCfg = configuration.derive(localTsp);
            innerCtx = DSL.using(derivedCfg);
        }
        else {
            // Use default configuration and transaction definition
            innerCtx = DSL.using(configuration);
        }

        innerCtx.insertInto()....
    });



Anyone have any opinions on this approach?

Cheers,
Steinar.

On Saturday, June 25, 2016 at 3:06:55 PM UTC+2, Denis Miorandi wrote:
>
> I could investigate about this...
> Il 25 giu 2016 2:34 PM, "Lukas Eder" <[email protected] <javascript:>> 
> ha scritto:
>
>> Hi Denis,
>>
>> I'm sorry for the delay.
>>
>> 2016-06-17 10:27 GMT+02:00 Denis Miorandi <[email protected] 
>> <javascript:>>:
>>
>>> 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. 
>>>
>>
>> The jOOQ model puts that responsibility into the 
>> Configuration.transactionProvider(), and implicitly also into 
>> Configuration.connectionProvider(). There is always a "current" 
>> Configuration, so the transaction semantics is clear.
>>  
>>
>>> 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.
>>>
>>
>> Unfortunately, I don't know it either. Would be interesting as a Stack 
>> Overflow question, I suspect. "How to get the current thread's context's 
>> @Transactional parameters via Spring APIs?"
>>
>> -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "jOOQ User Group" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/jooq-user/FVFKKVPheh4/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> [email protected] <javascript:>.
>> 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