default EntityManager recreateEntityManagerIfNecessary(final String persistenceUnitName) {
        val currentEntityManager = getEntityManager();
        return FunctionUtils.doIf(currentEntityManager == null && CasRuntimeHintsRegistrar.inNativeImage(), () -> {
            val entityManagerFactory = EntityManagerFactoryUtils.findEntityManagerFactory(getApplicationContext().getBeanFactory(), persistenceUnitName);
            return entityManagerFactory.createEntityManager();
        }, () -> currentEntityManager).get();
    }
Create entity manager.

@return the entity manager
support/cas-server-support-jpa-util/src/main/java/org/apereo/cas/configuration/support/JpaPersistenceUnitProvider.java