Java Code Examples for org.hibernate.boot.registry.StandardServiceRegistryBuilder#build()

The following examples show how to use org.hibernate.boot.registry.StandardServiceRegistryBuilder#build() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchemaExport.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private static StandardServiceRegistry buildStandardServiceRegistry(CommandLineArgs commandLineArgs)
		throws Exception {
	final BootstrapServiceRegistry bsr = new BootstrapServiceRegistryBuilder().build();
	final StandardServiceRegistryBuilder ssrBuilder = new StandardServiceRegistryBuilder( bsr );

	if ( commandLineArgs.cfgXmlFile != null ) {
		ssrBuilder.configure( commandLineArgs.cfgXmlFile );
	}

	Properties properties = new Properties();
	if ( commandLineArgs.propertiesFile != null ) {
		properties.load( new FileInputStream( commandLineArgs.propertiesFile ) );
	}
	ssrBuilder.applySettings( properties );

	return ssrBuilder.build();
}
 
Example 2
Source File: SchemaUpdate.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private static StandardServiceRegistry buildStandardServiceRegistry(CommandLineArgs parsedArgs) throws Exception {
	final BootstrapServiceRegistry bsr = new BootstrapServiceRegistryBuilder().build();
	final StandardServiceRegistryBuilder ssrBuilder = new StandardServiceRegistryBuilder( bsr );

	if ( parsedArgs.cfgXmlFile != null ) {
		ssrBuilder.configure( parsedArgs.cfgXmlFile );
	}

	if ( parsedArgs.propertiesFile != null ) {
		Properties props = new Properties();
		props.load( new FileInputStream( parsedArgs.propertiesFile ) );
		ssrBuilder.applySettings( props );
	}

	return ssrBuilder.build();
}
 
Example 3
Source File: SchemaValidator.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private static StandardServiceRegistry buildStandardServiceRegistry(CommandLineArgs parsedArgs) throws Exception {
	final BootstrapServiceRegistry bsr = new BootstrapServiceRegistryBuilder().build();
	final StandardServiceRegistryBuilder ssrBuilder = new StandardServiceRegistryBuilder( bsr );

	if ( parsedArgs.cfgXmlFile != null ) {
		ssrBuilder.configure( parsedArgs.cfgXmlFile );
	}

	if ( parsedArgs.propertiesFile != null ) {
		Properties properties = new Properties();
		properties.load( new FileInputStream( parsedArgs.propertiesFile ) );
		ssrBuilder.applySettings( properties );
	}

	return ssrBuilder.build();
}
 
Example 4
Source File: App.java    From juddi with Apache License 2.0 6 votes vote down vote up
/**
 * Method that actually creates the file.
 *
 * @param dbDialect to use
 */
private void generate(Dialect dialect) {

        StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder();
        ssrb.applySetting("hibernate.dialect", dialect.getDialectClass());
        StandardServiceRegistry standardServiceRegistry = ssrb.build();

        MetadataSources metadataSources = new MetadataSources(standardServiceRegistry);
        for (Class clzz : jpaClasses) {
                metadataSources.addAnnotatedClass(clzz);
        }

        Metadata metadata = metadataSources.buildMetadata();

        SchemaExport export = new SchemaExport();

        export.setDelimiter(";");
        export.setOutputFile(dialect.name().toLowerCase() + ".ddl");
        //export.execute(true, false, false, true);
        export.execute(EnumSet.of(TargetType.SCRIPT), Action.BOTH, metadata);
}
 
Example 5
Source File: JpaConfiguration.java    From micronaut-sql with Apache License 2.0 5 votes vote down vote up
/**
 * Builds the standard service registry.
 *
 * @param additionalSettings Additional settings for the service registry
 * @return The standard service registry
 */
@SuppressWarnings("WeakerAccess")
public StandardServiceRegistry buildStandardServiceRegistry(@Nullable Map<String, Object> additionalSettings) {
    StandardServiceRegistryBuilder standardServiceRegistryBuilder = createStandServiceRegistryBuilder(bootstrapServiceRegistry);

    Map<String, Object> jpaProperties = getProperties();
    if (CollectionUtils.isNotEmpty(jpaProperties)) {
        standardServiceRegistryBuilder.applySettings(jpaProperties);
    }
    if (additionalSettings != null) {
        standardServiceRegistryBuilder.applySettings(additionalSettings);
    }
    return standardServiceRegistryBuilder.build();
}
 
Example 6
Source File: HibernateUtil.java    From primefaces-blueprints with The Unlicense 5 votes vote down vote up
private static SessionFactory buildSessionFactory() throws HibernateException {
    Configuration configuration = new Configuration().configure();
    // configures settings from hibernate.cfg.xml

    StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder();

    // If you miss the below line then it will complain about a missing dialect setting
    serviceRegistryBuilder.applySettings(configuration.getProperties());

    ServiceRegistry serviceRegistry = serviceRegistryBuilder.build();
    return configuration.buildSessionFactory(serviceRegistry);
}
 
Example 7
Source File: HibernateUtil.java    From primefaces-blueprints with The Unlicense 5 votes vote down vote up
private static SessionFactory buildSessionFactory() throws HibernateException {
    Configuration configuration = new Configuration().configure();
    // configures settings from hibernate.cfg.xml

    StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder();

    // If you miss the below line then it will complain about a missing dialect setting
    serviceRegistryBuilder.applySettings(configuration.getProperties());

    ServiceRegistry serviceRegistry = serviceRegistryBuilder.build();
    return configuration.buildSessionFactory(serviceRegistry);
}
 
Example 8
Source File: Hbm2ddl.java    From wallride with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
	String locationPattern = "classpath:/org/wallride/domain/*";

	final BootstrapServiceRegistry registry = new BootstrapServiceRegistryBuilder().build();
	final MetadataSources metadataSources = new MetadataSources(registry);
	final StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder(registry);

	registryBuilder.applySetting(AvailableSettings.DIALECT, ExtendedMySQL5InnoDBDialect.class.getCanonicalName());
	registryBuilder.applySetting(AvailableSettings.GLOBALLY_QUOTED_IDENTIFIERS, true);
	registryBuilder.applySetting(AvailableSettings.PHYSICAL_NAMING_STRATEGY, PhysicalNamingStrategySnakeCaseImpl.class);

	final PathMatchingResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
	final Resource[] resources = resourcePatternResolver.getResources(locationPattern);
	final SimpleMetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
	for (Resource resource : resources) {
		MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
		AnnotationMetadata metadata = metadataReader.getAnnotationMetadata();
		if (metadata.hasAnnotation(Entity.class.getName())) {
			metadataSources.addAnnotatedClass(Class.forName(metadata.getClassName()));
		}
	}

	final StandardServiceRegistryImpl registryImpl = (StandardServiceRegistryImpl) registryBuilder.build();
	final MetadataBuilder metadataBuilder = metadataSources.getMetadataBuilder(registryImpl);

	new SchemaExport()
			.setHaltOnError(true)
			.setDelimiter(";")
			.create(EnumSet.of(TargetType.STDOUT), metadataBuilder.build());
}
 
Example 9
Source File: HibernateUtil.java    From primefaces-blueprints with The Unlicense 5 votes vote down vote up
private static SessionFactory buildSessionFactory() throws HibernateException {
    Configuration configuration = new Configuration().configure();
    // configures settings from hibernate.cfg.xml

    StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder();

    // If you miss the below line then it will complain about a missing dialect setting
    serviceRegistryBuilder.applySettings(configuration.getProperties());

    ServiceRegistry serviceRegistry = serviceRegistryBuilder.build();
    return configuration.buildSessionFactory(serviceRegistry);
}
 
Example 10
Source File: HibernateL2CacheSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Starts Hibernate.
 *
 * @param accessType Cache access type.
 * @param igniteInstanceName Ignite instance name.
 * @return Session factory.
 */
private SessionFactory startHibernate(org.hibernate.cache.spi.access.AccessType accessType, String igniteInstanceName) {
    StandardServiceRegistryBuilder builder = registryBuilder();

    for (Map.Entry<String, String> e : hibernateProperties(igniteInstanceName, accessType.name()).entrySet())
        builder.applySetting(e.getKey(), e.getValue());

    // Use the same cache for Entity and Entity2.
    builder.applySetting(REGION_CACHE_PROPERTY + ENTITY2_NAME, ENTITY_NAME);

    StandardServiceRegistry srvcRegistry = builder.build();

    MetadataSources metadataSources = new MetadataSources(srvcRegistry);

    for (Class entityClass : getAnnotatedClasses())
        metadataSources.addAnnotatedClass(entityClass);

    Metadata metadata = metadataSources.buildMetadata();

    for (PersistentClass entityBinding : metadata.getEntityBindings()) {
        if (!entityBinding.isInherited())
            ((RootClass) entityBinding).setCacheConcurrencyStrategy(accessType.getExternalName());
    }

    for (org.hibernate.mapping.Collection collectionBinding : metadata.getCollectionBindings())
        collectionBinding.setCacheConcurrencyStrategy(accessType.getExternalName());

    return metadata.buildSessionFactory();
}
 
Example 11
Source File: HibernateL2CacheStrategySelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param accessType Cache access typr.
 * @param igniteInstanceName Name of the grid providing caches.
 * @return Session factory.
 */
private SessionFactory startHibernate(AccessType accessType, String igniteInstanceName) {
    StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();

    builder.applySetting("hibernate.connection.url", CONNECTION_URL);

    for (Map.Entry<String, String> e : HibernateL2CacheSelfTest.hibernateProperties(igniteInstanceName, accessType.name()).entrySet())
        builder.applySetting(e.getKey(), e.getValue());

    builder.applySetting(USE_STRUCTURED_CACHE, "true");
    builder.applySetting(REGION_CACHE_PROPERTY + ENTITY1_NAME, "cache1");
    builder.applySetting(REGION_CACHE_PROPERTY + ENTITY2_NAME, "cache2");
    builder.applySetting(REGION_CACHE_PROPERTY + DEFAULT_UPDATE_TIMESTAMPS_REGION_UNQUALIFIED_NAME, DEFAULT_UPDATE_TIMESTAMPS_REGION_UNQUALIFIED_NAME);
    builder.applySetting(REGION_CACHE_PROPERTY + DEFAULT_QUERY_RESULTS_REGION_UNQUALIFIED_NAME, DEFAULT_QUERY_RESULTS_REGION_UNQUALIFIED_NAME);

    MetadataSources metadataSources = new MetadataSources(builder.build());

    metadataSources.addAnnotatedClass(Entity1.class);
    metadataSources.addAnnotatedClass(Entity2.class);
    metadataSources.addAnnotatedClass(Entity3.class);
    metadataSources.addAnnotatedClass(Entity4.class);

    Metadata metadata = metadataSources.buildMetadata();

    for (PersistentClass entityBinding : metadata.getEntityBindings()) {
        if (!entityBinding.isInherited())
            ((RootClass)entityBinding).setCacheConcurrencyStrategy(accessType.getExternalName());
    }

    return metadata.buildSessionFactory();
}
 
Example 12
Source File: HibernateL2CacheSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Starts Hibernate.
 *
 * @param accessType Cache access type.
 * @param igniteInstanceName Ignite instance name.
 * @return Session factory.
 */
private SessionFactory startHibernate(org.hibernate.cache.spi.access.AccessType accessType, String igniteInstanceName) {
    StandardServiceRegistryBuilder builder = registryBuilder();

    for (Map.Entry<String, String> e : hibernateProperties(igniteInstanceName, accessType.name()).entrySet())
        builder.applySetting(e.getKey(), e.getValue());

    // Use the same cache for Entity and Entity2.
    builder.applySetting(REGION_CACHE_PROPERTY + ENTITY2_NAME, ENTITY_NAME);

    StandardServiceRegistry srvcRegistry = builder.build();

    MetadataSources metadataSources = new MetadataSources(srvcRegistry);

    for (Class entityClass : getAnnotatedClasses())
        metadataSources.addAnnotatedClass(entityClass);

    Metadata metadata = metadataSources.buildMetadata();

    for (PersistentClass entityBinding : metadata.getEntityBindings()) {
        if (!entityBinding.isInherited())
            ((RootClass)entityBinding).setCacheConcurrencyStrategy(accessType.getExternalName());
    }

    for (org.hibernate.mapping.Collection collectionBinding : metadata.getCollectionBindings())
        collectionBinding.setCacheConcurrencyStrategy(accessType.getExternalName() );

    return metadata.buildSessionFactory();
}
 
Example 13
Source File: HibernateUtil.java    From primefaces-blueprints with The Unlicense 5 votes vote down vote up
private static SessionFactory buildSessionFactory() throws HibernateException {
    Configuration configuration = new Configuration().configure();
    // configures settings from hibernate.cfg.xml

    StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder();

    // If you miss the below line then it will complain about a missing dialect setting
    serviceRegistryBuilder.applySettings(configuration.getProperties());

    ServiceRegistry serviceRegistry = serviceRegistryBuilder.build();
    return configuration.buildSessionFactory(serviceRegistry);
}
 
Example 14
Source File: HibernateUtil.java    From primefaces-blueprints with The Unlicense 5 votes vote down vote up
private static SessionFactory buildSessionFactory() throws HibernateException {
    Configuration configuration = new Configuration().configure();
    // configures settings from hibernate.cfg.xml

    StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder();

    // If you miss the below line then it will complain about a missing dialect setting
    serviceRegistryBuilder.applySettings(configuration.getProperties());

    ServiceRegistry serviceRegistry = serviceRegistryBuilder.build();
    return configuration.buildSessionFactory(serviceRegistry);
}
 
Example 15
Source File: BaseCoreFunctionalTestCase.java    From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected StandardServiceRegistryImpl buildServiceRegistry(BootstrapServiceRegistry bootRegistry, Configuration configuration) {
  Properties properties = new Properties();
  properties.putAll( configuration.getProperties() );
  ConfigurationHelper.resolvePlaceHolders( properties );

  StandardServiceRegistryBuilder cfgRegistryBuilder = configuration.getStandardServiceRegistryBuilder();

  StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder( bootRegistry, cfgRegistryBuilder.getAggregatedCfgXml() )
      .applySettings( properties );

  prepareBasicRegistryBuilder( registryBuilder );
  return (StandardServiceRegistryImpl) registryBuilder.build();
}
 
Example 16
Source File: HibernateL2CacheMultiJvmTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * @param nodeName Name of the grid providing caches.
 * @return Session factory.
 */
SessionFactory startHibernate(String nodeName) {
    log.info("Start hibernate on node: " + nodeName);

    StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();

    for (Map.Entry<String, String> e : hibernateProperties(nodeName, NONSTRICT_READ_WRITE.name()).entrySet())
        builder.applySetting(e.getKey(), e.getValue());

    builder.applySetting("hibernate.connection.url", CONNECTION_URL);

    MetadataSources metadataSources = new MetadataSources(builder.build());

    metadataSources.addAnnotatedClass(Entity1.class);
    metadataSources.addAnnotatedClass(Entity2.class);
    metadataSources.addAnnotatedClass(Entity3.class);

    return metadataSources.buildMetadata().buildSessionFactory();
}
 
Example 17
Source File: HibernateL2CacheMultiJvmTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * @param nodeName Name of the grid providing caches.
 * @return Session factory.
 */
SessionFactory startHibernate(String nodeName) {
    log.info("Start hibernate on node: " + nodeName);

    StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();

    for (Map.Entry<String, String> e : hibernateProperties(nodeName, NONSTRICT_READ_WRITE.name()).entrySet())
        builder.applySetting(e.getKey(), e.getValue());

    builder.applySetting("hibernate.connection.url", CONNECTION_URL);

    MetadataSources metadataSources = new MetadataSources(builder.build());

    metadataSources.addAnnotatedClass(Entity1.class);
    metadataSources.addAnnotatedClass(Entity2.class);
    metadataSources.addAnnotatedClass(Entity3.class);

    return metadataSources.buildMetadata().buildSessionFactory();
}
 
Example 18
Source File: DBServiceImpl.java    From tp_java_2015_02 with MIT License 4 votes vote down vote up
private static SessionFactory createSessionFactory(Configuration configuration) {
    StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
    builder.applySettings(configuration.getProperties());
    ServiceRegistry serviceRegistry = builder.build();
    return configuration.buildSessionFactory(serviceRegistry);
}
 
Example 19
Source File: ModelDBHibernateUtil.java    From modeldb with Apache License 2.0 4 votes vote down vote up
public static SessionFactory createOrGetSessionFactory() throws ModelDBException {
  if (sessionFactory == null) {
    LOGGER.info("Fetching sessionFactory");
    try {
      App app = App.getInstance();
      Map<String, Object> databasePropMap = app.getDatabasePropMap();

      Map<String, Object> rDBPropMap =
          (Map<String, Object>) databasePropMap.get("RdbConfiguration");

      databaseName = (String) rDBPropMap.get("RdbDatabaseName");
      if (!app.getTraceEnabled()) {
        rDBDriver = (String) rDBPropMap.get("RdbDriver");
      } else {
        rDBDriver = "io.opentracing.contrib.jdbc.TracingDriver";
      }
      rDBUrl = (String) rDBPropMap.get("RdbUrl");
      rDBDialect = (String) rDBPropMap.get("RdbDialect");
      configUsername = (String) rDBPropMap.get("RdbUsername");
      configPassword = (String) rDBPropMap.get("RdbPassword");
      if (databasePropMap.containsKey("timeout")) {
        timeout = (Integer) databasePropMap.get("timeout");
      }
      liquibaseLockThreshold =
          Long.parseLong(databasePropMap.getOrDefault("liquibaseLockThreshold", "60").toString());

      // Change liquibase default table names
      System.getProperties().put("liquibase.databaseChangeLogTableName", "database_change_log");
      System.getProperties()
          .put("liquibase.databaseChangeLogLockTableName", "database_change_log_lock");

      // Hibernate settings equivalent to hibernate.cfg.xml's properties
      Configuration configuration = new Configuration();

      Properties settings = new Properties();

      String connectionString =
          rDBUrl
              + "/"
              + databaseName
              + "?createDatabaseIfNotExist=true&useUnicode=yes&characterEncoding=UTF-8";
      settings.put(Environment.DRIVER, rDBDriver);
      settings.put(Environment.URL, connectionString);
      settings.put(Environment.USER, configUsername);
      settings.put(Environment.PASS, configPassword);
      settings.put(Environment.DIALECT, rDBDialect);
      settings.put(Environment.HBM2DDL_AUTO, "validate");
      settings.put(Environment.SHOW_SQL, "false");
      configuration.setProperties(settings);

      LOGGER.trace("connectionString {}", connectionString);
      // Create registry builder
      StandardServiceRegistryBuilder registryBuilder =
          new StandardServiceRegistryBuilder().applySettings(settings);
      MetadataSources metaDataSrc = new MetadataSources(registryBuilder.build());
      for (Class entity : entities) {
        metaDataSrc.addAnnotatedClass(entity);
      }

      // Check DB is up or not
      boolean dbConnectionStatus =
          checkDBConnection(
              rDBDriver, rDBUrl, databaseName, configUsername, configPassword, timeout);
      if (!dbConnectionStatus) {
        checkDBConnectionInLoop(true);
      }

      releaseLiquibaseLock(metaDataSrc);

      // Run tables liquibase migration
      createTablesLiquibaseMigration(metaDataSrc);

      // Create session factory and validate entity
      sessionFactory = metaDataSrc.buildMetadata().buildSessionFactory();

      // Export schema
      if (ModelDBConstants.EXPORT_SCHEMA) {
        exportSchema(metaDataSrc.buildMetadata());
      }

      // Check if any migration need to be run or not and based on the migration status flag
      runMigration();

      LOGGER.info(ModelDBMessages.READY_STATUS, isReady);
      isReady = true;
      return sessionFactory;
    } catch (Exception e) {
      LOGGER.warn(
          "ModelDBHibernateUtil getSessionFactory() getting error : {}", e.getMessage(), e);
      if (registry != null) {
        StandardServiceRegistryBuilder.destroy(registry);
      }
      throw new ModelDBException(e.getMessage());
    }
  } else {
    return loopBack(sessionFactory);
  }
}
 
Example 20
Source File: EntityManagerFactoryBuilderImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private EntityManagerFactoryBuilderImpl(
		PersistenceUnitDescriptor persistenceUnit,
		Map integrationSettings,
		ClassLoader providedClassLoader,
		ClassLoaderService providedClassLoaderService) {

	LogHelper.logPersistenceUnitInformation( persistenceUnit );

	this.persistenceUnit = persistenceUnit;

	if ( integrationSettings == null ) {
		integrationSettings = Collections.emptyMap();
	}

	// Build the boot-strap service registry, which mainly handles class loader interactions
	final BootstrapServiceRegistry bsr = buildBootstrapServiceRegistry( integrationSettings, providedClassLoader, providedClassLoaderService);

	// merge configuration sources and build the "standard" service registry
	final StandardServiceRegistryBuilder ssrBuilder = new StandardServiceRegistryBuilder( bsr );
	final MergedSettings mergedSettings = mergeSettings( persistenceUnit, integrationSettings, ssrBuilder );
	this.configurationValues = mergedSettings.getConfigurationValues();

	// Build the "standard" service registry
	ssrBuilder.applySettings( configurationValues );
	configure( ssrBuilder );
	this.standardServiceRegistry = ssrBuilder.build();
	configure( standardServiceRegistry, mergedSettings );

	final MetadataSources metadataSources = new MetadataSources( bsr );
	List<AttributeConverterDefinition> attributeConverterDefinitions = populate(
			metadataSources,
			mergedSettings,
			standardServiceRegistry
	);
	this.metamodelBuilder = (MetadataBuilderImplementor) metadataSources.getMetadataBuilder( standardServiceRegistry );
	populate( metamodelBuilder, mergedSettings, standardServiceRegistry, attributeConverterDefinitions );

	// todo : would be nice to have MetadataBuilder still do the handling of CfgXmlAccessService here
	//		another option is to immediately handle them here (probably in mergeSettings?) as we encounter them...
	final CfgXmlAccessService cfgXmlAccessService = standardServiceRegistry.getService( CfgXmlAccessService.class );
	if ( cfgXmlAccessService.getAggregatedConfig() != null ) {
		if ( cfgXmlAccessService.getAggregatedConfig().getMappingReferences() != null ) {
			for ( MappingReference mappingReference : cfgXmlAccessService.getAggregatedConfig().getMappingReferences() ) {
				mappingReference.apply( metadataSources );
			}
		}
	}

	this.managedResources = MetadataBuildingProcess.prepare(
			metadataSources,
			metamodelBuilder.getBootstrapContext()
	);

	applyMetadataBuilderContributor();


	withValidatorFactory( configurationValues.get( org.hibernate.cfg.AvailableSettings.JPA_VALIDATION_FACTORY ) );

	// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// push back class transformation to the environment; for the time being this only has any effect in EE
	// container situations, calling back into PersistenceUnitInfo#addClassTransformer

	final boolean dirtyTrackingEnabled = readBooleanConfigurationValue( AvailableSettings.ENHANCER_ENABLE_DIRTY_TRACKING );
	final boolean lazyInitializationEnabled = readBooleanConfigurationValue( AvailableSettings.ENHANCER_ENABLE_LAZY_INITIALIZATION );
	final boolean associationManagementEnabled = readBooleanConfigurationValue( AvailableSettings.ENHANCER_ENABLE_ASSOCIATION_MANAGEMENT );

	if ( dirtyTrackingEnabled || lazyInitializationEnabled || associationManagementEnabled ) {
		EnhancementContext enhancementContext = getEnhancementContext(
				dirtyTrackingEnabled,
				lazyInitializationEnabled,
				associationManagementEnabled
		);

		persistenceUnit.pushClassTransformer( enhancementContext );
	}

	// for the time being we want to revoke access to the temp ClassLoader if one was passed
	metamodelBuilder.applyTempClassLoader( null );
}