[ https://issues.apache.org/jira/browse/OLINGO-580?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14541221#comment-14541221 ]
Ivan Lucas Vargas commented on OLINGO-580: ------------------------------------------ Hi, Just to contribute with the issue, and also is the only way I found to get this working, I'll post some additional information. I followed the instructions given from [~chandan.v.a] above, but I was struggling with Hibernate saying me that there was no transaction in progress. As I'm using CDI, the logical way to get my local implementation of ODataJPATransaction was to inject the EntityManager via @PersistenceContext in order to call the em.joinTransaction() and have Hibernate tied to my transaction started at my begin() method implementation. The problem here is that the ODataJPAContextImpl class, inside the getEntityManager(), creates one EntityManager (by calling emf.createEntityManager()) for each request. This EntityManager is not the same as my @PersistenceContext injection, causing to have two EntityManagers for each request and, as consequence, the em.joinTransaction() was "joining the transaction" for the wrong EntityManager. This lead to the Hibernate error "no transaction in progress". So, the solution I found for this issue is to set the ODataJPAContext into my local implementation of the ODataJPATransaction and ask from the EntityManager created from the ODataJPAContext itself. This way, I'm getting the same instance of the EntityManager created from Olingo and the getEntityManager().joinTransaction() works as expected. In my understanding, in this case, instead of calling the context.setEntityManagerFactory(), I should pass my instance (created from CDI) of the EntityManager (through a new method context.setEntityManager(), for instance) itself and Olingo should use it. Is this correct or I'm missing something? tks! > Support JTA based transactions in JPA processor > ----------------------------------------------- > > Key: OLINGO-580 > URL: https://issues.apache.org/jira/browse/OLINGO-580 > Project: Olingo > Issue Type: New Feature > Components: odata2-jpa > Affects Versions: V2 2.0.3 > Reporter: Chandan V.A > Assignee: Chandan V.A > Fix For: V2 2.0.4 > > Attachments: OLINGO-580.diff > > > Olingo V2 JPA processor supports RESOURCE_LOCAL based transaction. Enhance > the processor to support JTA based transactions. -- This message was sent by Atlassian JIRA (v6.3.4#6332)