getUserTransaction vs getNonPropagatingUserTransaction

spilby
Confirmed Champ
Confirmed Champ
The non-propagating (REQUIRES_NEW) ensures that the transaction is always new. I supose that the problem using the getUserTransaction is that if the transaction is already running, and I use that, may appears a concurrency problem. But using always a new transaction, could give me problems of performance?

I'm implementing a java backed webscript. A lot of users will use my service, and for each one the code will use 4 o 5 transactions. What's the better option? When is the best option use getNonPropagatingUserTransaction vs getUserTransaction?

Thanks!

2 REPLIES 2

kaynezhang
World-Class Innovator
World-Class Innovator
When your code is invoked from a non-transactional context, getNonPropagatingUserTransaction will behave exactly as getUserTransaction,they will all create a new transaction

When your code is invoked from a transactional context getNonPropagatingUserTransaction will suspend the current transaction and create a new one.

So which one to use depends on your semantics requirment instead of performance .
And no matter which you are using I don't think performance is a problem.

Oks! Thanks for the explanation Smiley Surprised)