/** * Does the descriptor and/or integration request Hibernate as the * {@link javax.persistence.spi.PersistenceProvider}? Note that in the case of no requested provider being named * we assume we are the provider (the calls got to us somehow...) * * @param persistenceUnit The {@code <persistence-unit/>} descriptor. * @param integration The integration values. * * @return {@code true} if Hibernate should be the provider; {@code false} otherwise. */ public static boolean isProvider(PersistenceUnitDescriptor persistenceUnit, Map integration) { // See if we (Hibernate) are the persistence provider return hibernateProviderNamesContain( extractRequestedProviderName( persistenceUnit, integration ) ); }
/** * Extract the requested persistence provider name using the algorithm Hibernate uses. Namely, a provider named * in the 'integration' map (under the key '{@value AvailableSettings#JPA_PERSISTENCE_PROVIDER}') is preferred, as per-spec, over * value specified in persistence unit. * * @param persistenceUnit The {@code <persistence-unit/>} descriptor. * @param integration The integration values. * * @return The extracted provider name, or {@code null} if none found. */ public static String extractRequestedProviderName(PersistenceUnitDescriptor persistenceUnit, Map integration) { final String integrationProviderName = extractProviderName( integration ); if ( integrationProviderName != null ) { log.debugf( "Integration provided explicit PersistenceProvider [%s]", integrationProviderName ); return integrationProviderName; } final String persistenceUnitRequestedProvider = extractProviderName( persistenceUnit ); if ( persistenceUnitRequestedProvider != null ) { log.debugf( "Persistence-unit [%s] requested PersistenceProvider [%s]", persistenceUnit.getName(), persistenceUnitRequestedProvider ); return persistenceUnitRequestedProvider; } // NOTE : if no provider requested we assume we are the provider (the calls got to us somehow...) log.debug( "No PersistenceProvider explicitly requested, assuming Hibernate" ); return HibernatePersistenceProvider.class.getName(); }
public static boolean isProvider(PersistenceUnitDescriptor persistenceUnit, Map<?, ?> integration) { if (ProviderChecker.isProvider(persistenceUnit, integration)) { return true; } String providerClassName = ProviderChecker.extractRequestedProviderName(persistenceUnit, integration); return HibernatePersistenceProvider.class.getName().equals(providerClassName); }
if ( ! ProviderChecker.isProvider( persistenceUnit, properties ) ) { log.debug( "Excluding from consideration due to provider mis-match" ); continue;
protected static EntityManagerFactoryBuilderImpl getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map<String, Object> properties, ClassLoader providedClassLoader) { final Map<String, Object> integration = wrap( properties ); final List<ParsedPersistenceXmlDescriptor> units; try { units = PersistenceXmlParser.locatePersistenceUnits( integration ); } catch (Exception e) { throw new PersistenceException( "Unable to locate persistence units", e ); } if ( persistenceUnitName == null && units.size() > 1 ) { throw new PersistenceException( "No name provided and multiple persistence units found" ); } for ( ParsedPersistenceXmlDescriptor persistenceUnit : units ) { final boolean matches = persistenceUnitName == null || persistenceUnit.getName().equals( persistenceUnitName ); if ( !matches ) { continue; } // See if we (Hibernate) are the persistence provider if ( ! ProviderChecker.isProvider( persistenceUnit, properties ) ) { continue; } return getEntityManagerFactoryBuilder( persistenceUnit, integration, providedClassLoader ); } return null; }
/** * Does the descriptor and/or integration request Hibernate as the * {@link javax.persistence.spi.PersistenceProvider}? Note that in the case of no requested provider being named * we assume we are the provider (the calls got to us somehow...) * * @param persistenceUnit The {@code <persistence-unit/>} descriptor. * @param integration The integration values. * * @return {@code true} if Hibernate should be the provider; {@code false} otherwise. */ public static boolean isProvider(PersistenceUnitDescriptor persistenceUnit, Map integration) { // See if we (Hibernate) are the persistence provider return hibernateProviderNamesContain( extractRequestedProviderName( persistenceUnit, integration ) ); }
if ( ! ProviderChecker.isProvider( persistenceUnit, properties ) ) { log.debug( "Excluding from consideration due to provider mis-match" ); continue;
/** * Extract the requested persistence provider name using the algorithm Hibernate uses. Namely, a provider named * in the 'integration' map (under the key '{@value AvailableSettings#JPA_PERSISTENCE_PROVIDER}') is preferred, as per-spec, over * value specified in persistence unit. * * @param persistenceUnit The {@code <persistence-unit/>} descriptor. * @param integration The integration values. * * @return The extracted provider name, or {@code null} if none found. */ public static String extractRequestedProviderName(PersistenceUnitDescriptor persistenceUnit, Map integration) { final String integrationProviderName = extractProviderName( integration ); if ( integrationProviderName != null ) { log.debugf( "Integration provided explicit PersistenceProvider [%s]", integrationProviderName ); return integrationProviderName; } final String persistenceUnitRequestedProvider = extractProviderName( persistenceUnit ); if ( persistenceUnitRequestedProvider != null ) { log.debugf( "Persistence-unit [%s] requested PersistenceProvider [%s]", persistenceUnit.getName(), persistenceUnitRequestedProvider ); return persistenceUnitRequestedProvider; } // NOTE : if no provider requested we assume we are the provider (the calls got to us somehow...) log.debug( "No PersistenceProvider explicitly requested, assuming Hibernate" ); return HibernatePersistenceProvider.class.getName(); }