/** * Find an EntityManagerFactory with the given name in the current Spring * application context, falling back to a single default EntityManagerFactory * (if any) in case of no unit name specified. * @param unitName the name of the persistence unit (may be {@code null} or empty) * @param requestingBeanName the name of the requesting bean * @return the EntityManagerFactory * @throws NoSuchBeanDefinitionException if there is no such EntityManagerFactory in the context */ protected EntityManagerFactory findEntityManagerFactory(@Nullable String unitName, @Nullable String requestingBeanName) throws NoSuchBeanDefinitionException { String unitNameForLookup = (unitName != null ? unitName : ""); if (unitNameForLookup.isEmpty()) { unitNameForLookup = this.defaultPersistenceUnitName; } if (!unitNameForLookup.isEmpty()) { return findNamedEntityManagerFactory(unitNameForLookup, requestingBeanName); } else { return findDefaultEntityManagerFactory(requestingBeanName); } }
/** * Find an EntityManagerFactory with the given name in the current Spring * application context, falling back to a single default EntityManagerFactory * (if any) in case of no unit name specified. * @param unitName the name of the persistence unit (may be {@code null} or empty) * @param requestingBeanName the name of the requesting bean * @return the EntityManagerFactory * @throws NoSuchBeanDefinitionException if there is no such EntityManagerFactory in the context */ protected EntityManagerFactory findEntityManagerFactory(@Nullable String unitName, @Nullable String requestingBeanName) throws NoSuchBeanDefinitionException { String unitNameForLookup = (unitName != null ? unitName : ""); if (unitNameForLookup.isEmpty()) { unitNameForLookup = this.defaultPersistenceUnitName; } if (!unitNameForLookup.isEmpty()) { return findNamedEntityManagerFactory(unitNameForLookup, requestingBeanName); } else { return findDefaultEntityManagerFactory(requestingBeanName); } }
/** * Find an EntityManagerFactory with the given name in the current Spring * application context, falling back to a single default EntityManagerFactory * (if any) in case of no unit name specified. * @param unitName the name of the persistence unit (may be {@code null} or empty) * @param requestingBeanName the name of the requesting bean * @return the EntityManagerFactory * @throws NoSuchBeanDefinitionException if there is no such EntityManagerFactory in the context */ protected EntityManagerFactory findEntityManagerFactory(@Nullable String unitName, @Nullable String requestingBeanName) throws NoSuchBeanDefinitionException { String unitNameForLookup = (unitName != null ? unitName : ""); if (unitNameForLookup.isEmpty()) { unitNameForLookup = this.defaultPersistenceUnitName; } if (!unitNameForLookup.isEmpty()) { return findNamedEntityManagerFactory(unitNameForLookup, requestingBeanName); } else { return findDefaultEntityManagerFactory(requestingBeanName); } }