Hi Gerald,

I found out issues in my code when I started to check whether transaction 
is indeed started when I execute my service call; and I found out it wasn't.

To find this out, I used the following: 
org.springframework.transaction.support.TransactionSynchronizationManager.isActualTransactionActive()


I then noticed issues in other parts of my code which I fixed and then 
verified that the service method executes in the context of a transaction.

Your answer helped me get pointers in the right direction; and your point 
about rollbackFor tag was also very helpful.

My sincere thanks to you for spending your valuable time in responding to 
me, and giving me useful pointers.

Thanks and Regards,
Sachin 

On Thursday, 3 April 2014 19:23:48 UTC+5:30, Gérald Quintana wrote:
>
> Personnally, I use the debugger: place a breakpoint in service method and 
> observe in the debugger the stacktrace. Alternatively you can use 
> Thread.dumpStack() and check std out.
>
> Gérald
>
>
> Le jeudi 3 avril 2014 13:56:26 UTC+2, Sachin Kulkarni a écrit :
>>
>> Hi Gerald,
>>
>> Thanks for your quick response.
>>
>> I have marked the transaction with propagation = Propagation.REQUIRED, 
>> rollbackFor={Exception.class} attributes.
>>
>> But this doesn't work.
>>
>> Can you please tell me how I can check TransactionInteceptor is present? 
>> I tried to place a break point in the method; but don't know how to detect 
>> this. I have enabled logging at the debug level; but can't find anything 
>> there.
>>
>> Your help is greatly appreciated.
>>
>> Thanks and Regards,
>> Sachin 
>>
>> On Thursday, 3 April 2014 16:32:22 UTC+5:30, Gérald Quintana wrote:
>>>
>>> Hi Sachin,
>>>
>>> First check the TransactionInterceptor aspect is properly applied on 
>>> your service class: you can place breakpoint in the method and check that 
>>> TransactionInteceptor is present, or you can place a breakpoint un 
>>> TransactionInterceptor.
>>>
>>> Then, what kind of Exception is thrown? By default, Spring only 
>>> rollbacks RuntimeException, jOOQ exceptions fall into this category. Did 
>>> you override exception handling 
>>> @Transactional(rollbackFor={MyCustomException.class})?
>>>
>>> Gerald
>>>
>>> Le jeudi 3 avril 2014 12:19:01 UTC+2, Sachin Kulkarni a écrit :
>>>>
>>>> Hi,
>>>>
>>>> I'm working on a spring (4.0.2)+ JOOQ (3.3.0) project, where I'm facing 
>>>> issue with transactions.
>>>> I have set up the jooq datasource connection provider to be 
>>>> transaction-aware in my servlet context as below:
>>>>
>>>>      <bean id="transactionAwareDataSource"
>>>>         
>>>> class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy">
>>>>         <constructor-arg ref="dataSource" />
>>>>     </bean>
>>>>
>>>>     <bean class="org.jooq.impl.DataSourceConnectionProvider" 
>>>> name="connectionProvider">
>>>>         <constructor-arg ref="transactionAwareDataSource" />
>>>>     </bean>
>>>>
>>>> I have methods in my service class which are decorated with 
>>>> @Transactional. However, when an exception occurs, I find that the 
>>>> transaction doesn't get rolled back (i.e. the database inserts I did in 
>>>> the 
>>>> service method get stored in db).
>>>>
>>>> However, if I explicitly start a transaction myself in the method like 
>>>> so:
>>>>    TransactionStatus tx = txMgr.getTransaction(new 
>>>> DefaultTransactionDefinition());
>>>> and roll it back myself in exception handler like so:
>>>>    txMgr.rollback(tx);
>>>>
>>>> That seems to work as I expect.
>>>>
>>>> What am I possibly missing to make @Transactional declaration work as 
>>>> we expect them to work with JOOQ?
>>>>
>>>> Thanks and Regards,
>>>> Sachin
>>>>
>>>>
>>>>

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