You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/08/11 05:24:22 UTC

[GitHub] [camel] zhfeng commented on a diff in pull request #8141: CAMEL-18377: camel-jpa - resue an EntityManager from the current tran…

zhfeng commented on code in PR #8141:
URL: https://github.com/apache/camel/pull/8141#discussion_r943104211


##########
components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaHelper.java:
##########
@@ -60,6 +62,15 @@ public static EntityManager getTargetEntityManager(
             em = getEntityManagerMap(exchange).get(getKey(entityManagerFactory));
         }
 
+        // then try to reuse one from the current transaction if possible
+        if (em == null && TransactionSynchronizationManager.hasResource(entityManagerFactory)) {

Review Comment:
   It's not good to reuse the one from JpaTransactionManager. I just wonder if there is any way to reuse one in current transaction
   
   ```java
   if (em == null && exchange != null && exhange.isTransacted()) {
       // get em from the transaction context in camel?
   }
   ```
   
   @davsclaus any thoughts here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org