private EntityManager getNonTxEMFromCurrentInvocation() {
// We store nonTxEM as a payload in a map from EMF to EM inside current invocation.
// It will be closed during NonTxEntityManagerCleaner.beforePostInvoke() below
ComponentInvocation currentInvocation = invMgr.getCurrentInvocation();
Map<EntityManagerFactory, EntityManager> nonTxEMs = getNonTxEMsFromCurrentInvocation(currentInvocation);
if(nonTxEMs == null) {
nonTxEMs = new HashMap<>();
currentInvocation.setRegistryFor(INVOCATION_PAYLOAD_KEY, nonTxEMs);
}
EntityManager nonTxEM = nonTxEMs.get(entityManagerFactory);
if(nonTxEM == null) {
// Could not find one, create new one and store it within current invocation for cleanup
nonTxEM = entityManagerFactory.createEntityManager(synchronizationType, emProperties);