if (jpaDeploymentSettings != null) {
useDeepInheritance = ExtendedPersistenceInheritance.DEEP.equals(jpaDeploymentSettings.getExtendedPersistenceInheritanceType());
}
boolean createdNewExtendedPersistence = false;
ExtendedEntityManager entityManager1;
// handle PersistenceContextType.EXTENDED
if (useDeepInheritance) {
entityManager1 = ExtendedPersistenceDeepInheritance.INSTANCE.findExtendedPersistenceContext(unitName);
}
else {
entityManager1 = ExtendedPersistenceShallowInheritance.INSTANCE.findExtendedPersistenceContext(unitName);
}
if (entityManager1 == null) {
entityManager1 = new ExtendedEntityManager(unitName, emf.createEntityManager(properties), synchronizationType);
createdNewExtendedPersistence = true;
if (JPA_LOGGER.isDebugEnabled())
JPA_LOGGER.debugf("created new ExtendedEntityManager for unit name=%s, useDeepInheritance = %b", unitName, useDeepInheritance);
} else {
entityManager1.increaseReferenceCount();
if (JPA_LOGGER.isDebugEnabled())
JPA_LOGGER.debugf("inherited existing ExtendedEntityManager from SFSB invocation stack, unit name=%s, " +
"%d beans sharing ExtendedEntityManager, useDeepInheritance = %b", unitName, entityManager1.getReferenceCount(), useDeepInheritance);
}
entityManager = entityManager1;
// register the EntityManager on TL so that SFSBCreateInterceptor will see it.