You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aries.apache.org by Timothy Ward <ti...@apache.org> on 2018/04/11 14:26:05 UTC

Re: ARIES-1783 TransactionRequiredException when non-transactional method precedes a transactional one in the same service.

Hi,

I’m afraid that the answer to this is non-trivial.

Section 3.3 of the JPA specification indicates that In the case of a Transaction scoped persistence context you should be getting a new entity manager instance in the new transaction (i.e. not calling joinTransaction). 

In the case of an extended scope persistence context then it should join the current transaction if the entity manager is not already joined to the current transaction

Regards,

Tim

> On 15 Mar 2018, at 16:26, Daniel Estermann <so...@gmail.com> wrote:
> 
> Hi everybody,
> 
> I write to this mailing list because I reported ARIES-1783
> <https://issues.apache.org/jira/browse/ARIES-1783> and also tried to
> investigate why the exception occurs.
> 
> Both in our productive environment as well as in the integration tests (for
> which I created a test in my pull request
> <https://github.com/apache/aries-jpa/pull/2>) I came to the same
> conclusion: In the subject case the exception occurs, because the join
> status of the transaction is NOT_JOINED. I discovered it by looking at
> TransactionCoordinatorImpl#isTransactionInProgress()
> <https://github.com/CodingFabian/hibernate-core/blob/03ecaba4b035dd8f4ad1b506dd8ebd73ff3d77f8/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/TransactionCoordinatorImpl.java#L160>,
> which returns false.
> 
> What seems to help is to call joinTransaction() on the EntityManager in the
> beginning of a method annotated with REQUIRES_NEW. However I can't tell if
> that would be a proper fix. It feels at least not as proper solution.
> 
> I would appreciate any support on that issue.
> 
> Kind Regards
> Daniel