}
protected EntityManager getEntityManager()
{
String kernelName = persistenceUnit.getName();
PersistenceUnit pu = PersistenceUnitRegistry.getPersistenceUnit(kernelName);
XPCResolver xpcResolver = pu.getXPCResolver();
EntityManager em = xpcResolver.getExtendedPersistenceContext(kernelName);
if(em != null)
return em;
return persistenceUnit.getTransactionScopedEntityManager();