Lukas,

I was giving a thought about it. The pattern doesn't seems to be fitting in
my head now. I'm using the pattern above in a REST call scenario. In first
case, if there is a global listener, how will I return the exceptions to
each caller? Imagine if there are 3,4 calls concurrently, even though the
listener catches up the exception, I guess there is no way to throw that to
the caller uniquely (so that I can show up the error message etc in the UI).

May be I'm wrong here.

On Thu, Apr 27, 2017 at 1:02 PM, Anto Aravinth <[email protected]>
wrote:

> Thanks Lukas, will look into that.
>
> On Thu, Apr 27, 2017 at 12:38 PM, Lukas Eder <[email protected]> wrote:
>
>> You put that in your global Configuration, i.e the one you used to create
>> your dslContext:
>> https://www.jooq.org/javadoc/latest/org/jooq/Configuration.h
>> tml#derive-org.jooq.TransactionListener...-
>>
>> This isn't a per-transaction SPI, it's a global one, like the other SPIs
>> in the Configuration.
>>
>> Unfortunately, we currently don't have a manual section describing this
>> SPI (will do soon). But it works like this:
>>
>>
>> Configuration global = new DefaultConfiguration()
>>    .set(connectionProvider)
>>    .set(transactionProvider)
>>    .set(dialect)
>>    .set(settings)
>>    .set(transactionListener);
>>
>> DSLContext dslContext = DSL.using(global);
>>
>> dslContext.transaction(configuration -> {
>>     /* transactional code here. Exceptions can be listened to from the
>> above transactionListener */
>> });
>>
>>
>> 2017-04-27 8:50 GMT+02:00 Anto Aravinth <[email protected]>:
>>
>>> Hi Lukas,
>>>
>>> Thanks for your response. But I have a question, if I implement the 
>>> TransactionListener
>>> API, how should I pass that to the current executing transaction? Any
>>> examples repo will be really great.
>>>
>>> On Thu, Apr 27, 2017 at 11:53 AM, Lukas Eder <[email protected]>
>>> wrote:
>>>
>>>> Hi Anto,
>>>>
>>>> Thanks for your message. jOOQ 3.9 added support for a
>>>> TransactionListener SPI:
>>>>
>>>> - https://github.com/jOOQ/jOOQ/issues/5378
>>>> - https://www.jooq.org/javadoc/latest/org/jooq/TransactionListener.html
>>>>
>>>> It will allow you to get a hold of the cause for any rollback:
>>>> https://www.jooq.org/javadoc/latest/org/jooq/TransactionCont
>>>> ext.html#cause--
>>>>
>>>> I hope this helps,
>>>> Lukas
>>>>
>>>> 2017-04-27 8:05 GMT+02:00 Anto Aravinth <[email protected]>:
>>>>
>>>>> Hi,
>>>>>
>>>>> I'm new to jooq and trying to do the following. I wanted to insert a
>>>>> data into the table. I'm running the following code in a transaction:
>>>>>
>>>>> dslContext.transaction(configuration -> {
>>>>>     DSLContext ctx = DSL.using(configuration);
>>>>>     ctx
>>>>>    .insertInto(USERDATA,USERDATA.USERNAME,USERDATA.PASSWORD)
>>>>>    .values(username,password)
>>>>>    .returning()
>>>>>    .fetchOne();
>>>>> });
>>>>>
>>>>> Now I want to understand that within a transaction how will I come to
>>>>> know if the code inside it was successful or not? (only with exceptions).
>>>>> How to do that? Also let me know how to get to know about exceptions, say
>>>>> if an exception occurs on duplicate value etc.
>>>>>
>>>>> Thanks for your response.
>>>>>
>>>>>
>>>>> --
>>>>> 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 a topic in the
>>>> Google Groups "jOOQ User Group" group.
>>>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>>>> pic/jooq-user/jtT55WSNu30/unsubscribe.
>>>> To unsubscribe from this group and all its topics, 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.
>>>
>>
>> --
>> 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/to
>> pic/jooq-user/jtT55WSNu30/unsubscribe.
>> To unsubscribe from this group and all its topics, 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