Skip to content

Commit

Permalink
[JBPM-10087] Trying to create new transaction to perform query (#2274)
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtirado authored Mar 16, 2023
1 parent e384df9 commit 454fe3d
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,26 @@ private TimerMappingInfo getTimerMappingInfo(Function<EntityManager, List<TimerM
String pu = ((InternalRuntimeManager) manager).getDeploymentDescriptor().getPersistenceUnit();
EntityManagerFactory emf = EntityManagerFactoryManager.get().getOrCreate(pu);
EntityManager em = emf.createEntityManager();
JtaTransactionManager tm = (JtaTransactionManager) TransactionManagerFactory.get().newTransactionManager();
boolean txOwner = false;
try {
if (tm != null && tm.getStatus() == TransactionManager.STATUS_ROLLEDBACK) {
txOwner = tm.begin();
}
List<TimerMappingInfo> info = func.apply(em);
if (!info.isEmpty()) {
return info.get(0);
} else {
return null;
}

} catch (Exception ex) {
logger.warn("Error getting mapping info ",ex);
return null;
} finally {
if (tm != null) {
tm.commit(txOwner);
}
em.close();
}
}
Expand Down

0 comments on commit 454fe3d

Please sign in to comment.