private static RegionFactory createRegionFactory(
     Properties properties, boolean cachingEnabled, ServiceRegistry serviceRegistry) {
   String regionFactoryClassName =
       RegionFactoryInitiator.mapLegacyNames(
           ConfigurationHelper.getString(
               AvailableSettings.CACHE_REGION_FACTORY, properties, null));
   if (regionFactoryClassName == null || !cachingEnabled) {
     regionFactoryClassName = DEF_CACHE_REG_FACTORY;
   }
   LOG.debugf("Cache region factory : %s", regionFactoryClassName);
   try {
     try {
       return (RegionFactory)
           serviceRegistry
               .getService(ClassLoaderService.class)
               .classForName(regionFactoryClassName)
               .getConstructor(Properties.class)
               .newInstance(properties);
     } catch (NoSuchMethodException e) {
       // no constructor accepting Properties found, try no arg constructor
       LOG.debugf(
           "%s did not provide constructor accepting java.util.Properties; attempting no-arg constructor.",
           regionFactoryClassName);
       return (RegionFactory)
           serviceRegistry
               .getService(ClassLoaderService.class)
               .classForName(regionFactoryClassName)
               .newInstance();
     }
   } catch (Exception e) {
     throw new HibernateException(
         "could not instantiate RegionFactory [" + regionFactoryClassName + "]", e);
   }
 }
  /**
   * There are 2 solutions: 1. DatabaseCollector#addTable()/getTable() should be called for not
   * quoted parameters - I think it is preferable way. 2. DatabaseCollector#addTable()/getTable()
   * should be called for quoted parameters - here users should use the same quotes as JDBCReader.
   * Because of this there are 2 opposite methods(and they are both failed as addTable uses quoted
   * names but getTable uses non-quoted names )
   */
  public void testQuotedNamesAndDefaultDatabaseCollector() {
    StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
    ServiceRegistry serviceRegistry = builder.build();

    MetaDataDialect realMetaData =
        MetaDataDialectFactory.createMetaDataDialect(
            serviceRegistry.getService(JdbcServices.class).getDialect(), cfg.getProperties());

    JDBCReader reader =
        JDBCReaderFactory.newJDBCReader(
            cfg.getProperties(),
            new DefaultReverseEngineeringStrategy(),
            realMetaData,
            serviceRegistry);

    DatabaseCollector dc = new DefaultDatabaseCollector(reader.getMetaDataDialect());
    reader.readDatabaseSchema(dc, null, SCHEMA);

    assertNotNull("The table should be found", dc.getTable(SCHEMA, "PUBLIC", TABLE1));
    assertNotNull("The table should be found", dc.getTable(SCHEMA, "PUBLIC", TABLE2));
    assertNull(
        "Quoted names should not return the table", dc.getTable(quote(SCHEMA), "PUBLIC", QTABLE1));
    assertNull(
        "Quoted names should not return the table", dc.getTable(quote(SCHEMA), "PUBLIC", QTABLE2));

    assertEquals("Foreign key 'masterref' was filtered!", 1, dc.getOneToManyCandidates().size());
  }
  public static InfinispanRegionFactory startRegionFactory(ServiceRegistry serviceRegistry) {
    try {
      final ConfigurationService cfgService =
          serviceRegistry.getService(ConfigurationService.class);

      String factoryType =
          cfgService.getSetting(AvailableSettings.CACHE_REGION_FACTORY, StandardConverters.STRING);
      Class clazz = Thread.currentThread().getContextClassLoader().loadClass(factoryType);
      InfinispanRegionFactory regionFactory;
      if (clazz == InfinispanRegionFactory.class) {
        regionFactory = new SingleNodeTestCase.TestInfinispanRegionFactory();
      } else {
        regionFactory = (InfinispanRegionFactory) clazz.newInstance();
      }

      final SessionFactoryOptionsImpl sessionFactoryOptions =
          new SessionFactoryOptionsImpl(
              new SessionFactoryBuilderImpl.SessionFactoryOptionsStateStandardImpl(
                  (StandardServiceRegistry) serviceRegistry));
      final Properties properties = toProperties(cfgService.getSettings());

      regionFactory.start(sessionFactoryOptions, properties);

      return regionFactory;
    } catch (RuntimeException e) {
      throw e;
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
  public static AnnotationTarget getTarget(
      ServiceRegistry serviceRegistry, ClassInfo classInfo, String name, TargetType type) {
    Class clazz =
        serviceRegistry.getService(ClassLoaderService.class).classForName(classInfo.toString());
    switch (type) {
      case FIELD:
        Field field = getField(clazz, name);
        if (field == null) {
          throw new HibernateException(
              "Unable to load field " + name + " of class " + clazz.getName());
        }

        return FieldInfo.create(
            classInfo, name, getType(field.getType()), (short) (field.getModifiers()));
      case METHOD:
        Method method = getMethod(clazz, name);
        if (method == null) {
          throw new HibernateException(
              "Unable to load method " + name + " of class " + clazz.getName());
        }
        return getMethodInfo(classInfo, method);
      case PROPERTY:
        method = getterMethod(clazz, name);
        if (method == null) {
          throw new HibernateException(
              "Unable to load property " + name + " of class " + clazz.getName());
        }
        return getMethodInfo(classInfo, method);
    }
    throw new HibernateException("");
  }
Exemple #5
0
 public static Class classForName(String className, ServiceRegistry serviceRegistry) {
   ClassLoaderService classLoaderService = serviceRegistry.getService(ClassLoaderService.class);
   try {
     return classLoaderService.classForName(className);
   } catch (ClassLoadingException e) {
     throw new MappingException("Could not find class: " + className);
   }
 }
  public void testNeedQuote() {
    ServiceRegistry serviceRegistry = cfg.getServiceRegistry();

    MetaDataDialect realMetaData =
        MetaDataDialectFactory.createMetaDataDialect(
            serviceRegistry.getService(JdbcServices.class).getDialect(), cfg.getProperties());
    assertTrue("The name must be quoted!", realMetaData.needQuote(SCHEMA));
    assertTrue("The name must be quoted!", realMetaData.needQuote(TABLE1));
    assertTrue("The name must be quoted!", realMetaData.needQuote(TABLE2));
  }
  public void initialize(Configuration cfg, ServiceRegistry serviceRegistry, Settings settings) {

    super.initialize(cfg, serviceRegistry, settings);
    JdbcServices jdbcServices = serviceRegistry.getService(JdbcServices.class);
    dialect = jdbcServices.getDialect();

    tableSelector = new TableSelectorStrategy(new DefaultReverseEngineeringStrategy());
    reader = JDBCReaderFactory.newJDBCReader(serviceRegistry, settings, tableSelector);
    dbc = new DefaultDatabaseCollector(reader.getMetaDataDialect());
    mapping = cfg.buildMapping();
  }
Exemple #8
0
  public SchemaExport(MetadataImplementor metadata) {
    ServiceRegistry serviceRegistry = metadata.getServiceRegistry();
    this.connectionHelper =
        new SuppliedConnectionProviderConnectionHelper(
            serviceRegistry.getService(ConnectionProvider.class));
    JdbcServices jdbcServices = serviceRegistry.getService(JdbcServices.class);
    this.sqlStatementLogger = jdbcServices.getSqlStatementLogger();
    this.formatter =
        (sqlStatementLogger.isFormat() ? FormatStyle.DDL : FormatStyle.NONE).getFormatter();
    this.sqlExceptionHelper = jdbcServices.getSqlExceptionHelper();

    this.importFiles =
        ConfigurationHelper.getString(
            AvailableSettings.HBM2DDL_IMPORT_FILES,
            serviceRegistry.getService(ConfigurationService.class).getSettings(),
            DEFAULT_IMPORT_FILE);

    final Dialect dialect = jdbcServices.getDialect();
    this.dropSQL = metadata.getDatabase().generateDropSchemaScript(dialect);
    this.createSQL = metadata.getDatabase().generateSchemaCreationScript(dialect);
  }
Exemple #9
0
  public SchemaExport(ServiceRegistry serviceRegistry, Configuration configuration) {
    this.connectionHelper =
        new SuppliedConnectionProviderConnectionHelper(
            serviceRegistry.getService(ConnectionProvider.class));
    this.sqlStatementLogger =
        serviceRegistry.getService(JdbcServices.class).getSqlStatementLogger();
    this.formatter =
        (sqlStatementLogger.isFormat() ? FormatStyle.DDL : FormatStyle.NONE).getFormatter();
    this.sqlExceptionHelper =
        serviceRegistry.getService(JdbcServices.class).getSqlExceptionHelper();

    this.importFiles =
        ConfigurationHelper.getString(
            AvailableSettings.HBM2DDL_IMPORT_FILES,
            configuration.getProperties(),
            DEFAULT_IMPORT_FILE);

    final Dialect dialect = serviceRegistry.getService(JdbcServices.class).getDialect();
    this.dropSQL = configuration.generateDropSchemaScript(dialect);
    this.createSQL = configuration.generateSchemaCreationScript(dialect);
  }
 protected QueryTranslatorFactory createQueryTranslatorFactory(
     Properties properties, ServiceRegistry serviceRegistry) {
   String className =
       ConfigurationHelper.getString(
           AvailableSettings.QUERY_TRANSLATOR,
           properties,
           "org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory");
   LOG.debugf("Query translator: %s", className);
   try {
     return (QueryTranslatorFactory)
         serviceRegistry
             .getService(ClassLoaderService.class)
             .classForName(className)
             .newInstance();
   } catch (Exception e) {
     throw new HibernateException("could not instantiate QueryTranslatorFactory: " + className, e);
   }
 }
 protected QueryCacheFactory createQueryCacheFactory(
     Properties properties, ServiceRegistry serviceRegistry) {
   String queryCacheFactoryClassName =
       ConfigurationHelper.getString(
           AvailableSettings.QUERY_CACHE_FACTORY,
           properties,
           StandardQueryCacheFactory.class.getName());
   LOG.debugf("Query cache factory: %s", queryCacheFactoryClassName);
   try {
     return (QueryCacheFactory)
         serviceRegistry
             .getService(ClassLoaderService.class)
             .classForName(queryCacheFactoryClassName)
             .newInstance();
   } catch (Exception e) {
     throw new HibernateException(
         "could not instantiate QueryCacheFactory: " + queryCacheFactoryClassName, e);
   }
 }
Exemple #12
0
/* 285:    */   
/* 286:    */   static AnnotationTarget getTarget(ServiceRegistry serviceRegistry, ClassInfo classInfo, String name, TargetType type)
/* 287:    */   {
/* 288:322 */     Class clazz = ((ClassLoaderService)serviceRegistry.getService(ClassLoaderService.class)).classForName(classInfo.toString());
/* 289:    */     Method method;
/* 290:323 */     switch (1.$SwitchMap$org$hibernate$metamodel$source$annotations$xml$mocker$MockHelper$TargetType[type.ordinal()])
/* 291:    */     {
/* 292:    */     case 1: 
/* 293:325 */       Field field = getField(clazz, name);
/* 294:326 */       if (field == null) {
/* 295:327 */         throw new HibernateException("Unable to load field " + name + " of class " + clazz.getName());
/* 296:    */       }
/* 297:334 */       return FieldInfo.create(classInfo, name, getType(field.getType()), (short)field.getModifiers());
/* 298:    */     case 2: 
/* 299:338 */       method = getMethod(clazz, name);
/* 300:339 */       if (method == null) {
/* 301:340 */         throw new HibernateException("Unable to load method " + name + " of class " + clazz.getName());
/* 302:    */       }
/* 303:346 */       return getMethodInfo(classInfo, method);
/* 304:    */     case 3: 
  @Override
  public void configure(Type type, Properties params, ServiceRegistry serviceRegistry)
      throws MappingException {
    final JdbcEnvironment jdbcEnvironment = serviceRegistry.getService(JdbcEnvironment.class);
    final Dialect dialect = jdbcEnvironment.getDialect();

    this.identifierType = type;
    boolean forceTableUse = ConfigurationHelper.getBoolean(FORCE_TBL_PARAM, params, false);

    final QualifiedName sequenceName = determineSequenceName(params, dialect, jdbcEnvironment);

    final int initialValue = determineInitialValue(params);
    int incrementSize = determineIncrementSize(params);

    final String optimizationStrategy = determineOptimizationStrategy(params, incrementSize);
    incrementSize = determineAdjustedIncrementSize(optimizationStrategy, incrementSize);

    if (dialect.supportsSequences() && !forceTableUse) {
      if (!dialect.supportsPooledSequences()
          && OptimizerFactory.isPooledOptimizer(optimizationStrategy)) {
        forceTableUse = true;
        LOG.forcingTableUse();
      }
    }

    this.databaseStructure =
        buildDatabaseStructure(
            type,
            params,
            jdbcEnvironment,
            forceTableUse,
            sequenceName,
            initialValue,
            incrementSize);
    this.optimizer =
        OptimizerFactory.buildOptimizer(
            optimizationStrategy,
            identifierType.getReturnedClass(),
            incrementSize,
            ConfigurationHelper.getInt(INITIAL_PARAM, params, -1));
    this.databaseStructure.prepare(optimizer);
  }
 ClassInfo createClassInfo(String className) {
   if (StringHelper.isEmpty(className)) {
     throw new AssertionFailure("Class Name used to create ClassInfo is empty.");
   }
   DotName classDotName = DotName.createSimple(className);
   if (classes.containsKey(classDotName)) {
     // classInfoAnnotationsMap.put( classDotName, new HashMap<DotName,
     // List<AnnotationInstance>>(classes.get( classDotName ).annotations()) );
     return classes.get(classDotName);
   }
   Class clazz = serviceRegistry.getService(ClassLoaderService.class).classForName(className);
   DotName superName = null;
   DotName[] interfaces = null;
   short access_flag;
   ClassInfo annClassInfo = index.getClassByName(classDotName);
   if (annClassInfo != null) {
     superName = annClassInfo.superName();
     interfaces = annClassInfo.interfaces();
     access_flag = annClassInfo.flags();
   } else {
     Class superClass = clazz.getSuperclass();
     if (superClass != null) {
       superName = DotName.createSimple(superClass.getName());
     }
     Class[] classInterfaces = clazz.getInterfaces();
     if (classInterfaces != null && classInterfaces.length > 0) {
       interfaces = new DotName[classInterfaces.length];
       for (int i = 0; i < classInterfaces.length; i++) {
         interfaces[i] = DotName.createSimple(classInterfaces[i].getName());
       }
     }
     access_flag = (short) (clazz.getModifiers() | 0x20); // (modifiers | ACC_SUPER)
   }
   Map<DotName, List<AnnotationInstance>> map = new HashMap<DotName, List<AnnotationInstance>>();
   classInfoAnnotationsMap.put(classDotName, map);
   ClassInfo classInfo = ClassInfo.create(classDotName, superName, access_flag, interfaces, map);
   classes.put(classDotName, classInfo);
   addSubClasses(superName, classInfo);
   addImplementors(interfaces, classInfo);
   return classInfo;
 }
 /**
  * Generates a proxy wrapping the ResultSet.
  *
  * @param resultSet The resultSet to wrap.
  * @param columnNameCache The cache storing data for converting column names to column indexes.
  * @param serviceRegistry Access to any needed services
  * @return The generated proxy.
  */
 public static ResultSet generateProxy(
     ResultSet resultSet, ColumnNameCache columnNameCache, ServiceRegistry serviceRegistry) {
   return serviceRegistry
       .getService(ClassLoaderService.class)
       .generateProxy(new ResultSetWrapperProxy(resultSet, columnNameCache), ResultSet.class);
 }
  public Settings buildSettings(Properties props, ServiceRegistry serviceRegistry) {
    final boolean debugEnabled = LOG.isDebugEnabled();
    final JdbcServices jdbcServices = serviceRegistry.getService(JdbcServices.class);
    Settings settings = new Settings();

    // SessionFactory name:

    String sessionFactoryName = props.getProperty(AvailableSettings.SESSION_FACTORY_NAME);
    settings.setSessionFactoryName(sessionFactoryName);
    settings.setSessionFactoryNameAlsoJndiName(
        ConfigurationHelper.getBoolean(
            AvailableSettings.SESSION_FACTORY_NAME_IS_JNDI, props, true));

    // JDBC and connection settings:

    // Interrogate JDBC metadata
    ExtractedDatabaseMetaData meta = jdbcServices.getExtractedMetaDataSupport();

    settings.setDataDefinitionImplicitCommit(meta.doesDataDefinitionCauseTransactionCommit());
    settings.setDataDefinitionInTransactionSupported(meta.supportsDataDefinitionInTransaction());

    // use dialect default properties
    final Properties properties = new Properties();
    properties.putAll(jdbcServices.getDialect().getDefaultProperties());
    properties.putAll(props);

    // Transaction settings:
    settings.setJtaPlatform(serviceRegistry.getService(JtaPlatform.class));

    MultiTableBulkIdStrategy multiTableBulkIdStrategy =
        serviceRegistry
            .getService(StrategySelector.class)
            .resolveStrategy(
                MultiTableBulkIdStrategy.class,
                properties.getProperty(AvailableSettings.HQL_BULK_ID_STRATEGY));
    if (multiTableBulkIdStrategy == null) {
      multiTableBulkIdStrategy =
          jdbcServices.getDialect().supportsTemporaryTables()
              ? TemporaryTableBulkIdStrategy.INSTANCE
              : new PersistentTableBulkIdStrategy();
    }
    settings.setMultiTableBulkIdStrategy(multiTableBulkIdStrategy);

    boolean flushBeforeCompletion =
        ConfigurationHelper.getBoolean(AvailableSettings.FLUSH_BEFORE_COMPLETION, properties);
    if (debugEnabled) {
      LOG.debugf(
          "Automatic flush during beforeCompletion(): %s", enabledDisabled(flushBeforeCompletion));
    }
    settings.setFlushBeforeCompletionEnabled(flushBeforeCompletion);

    boolean autoCloseSession =
        ConfigurationHelper.getBoolean(AvailableSettings.AUTO_CLOSE_SESSION, properties);
    if (debugEnabled) {
      LOG.debugf(
          "Automatic session close at end of transaction: %s", enabledDisabled(autoCloseSession));
    }
    settings.setAutoCloseSessionEnabled(autoCloseSession);

    // JDBC and connection settings:

    int batchSize =
        ConfigurationHelper.getInt(AvailableSettings.STATEMENT_BATCH_SIZE, properties, 0);
    if (!meta.supportsBatchUpdates()) {
      batchSize = 0;
    }
    if (batchSize > 0 && debugEnabled) {
      LOG.debugf("JDBC batch size: %s", batchSize);
    }
    settings.setJdbcBatchSize(batchSize);

    boolean jdbcBatchVersionedData =
        ConfigurationHelper.getBoolean(AvailableSettings.BATCH_VERSIONED_DATA, properties, false);
    if (batchSize > 0 && debugEnabled) {
      LOG.debugf(
          "JDBC batch updates for versioned data: %s", enabledDisabled(jdbcBatchVersionedData));
    }
    settings.setJdbcBatchVersionedData(jdbcBatchVersionedData);

    boolean useScrollableResultSets =
        ConfigurationHelper.getBoolean(
            AvailableSettings.USE_SCROLLABLE_RESULTSET,
            properties,
            meta.supportsScrollableResults());
    if (debugEnabled) {
      LOG.debugf("Scrollable result sets: %s", enabledDisabled(useScrollableResultSets));
    }
    settings.setScrollableResultSetsEnabled(useScrollableResultSets);

    boolean wrapResultSets =
        ConfigurationHelper.getBoolean(AvailableSettings.WRAP_RESULT_SETS, properties, false);
    if (debugEnabled) {
      LOG.debugf("Wrap result sets: %s", enabledDisabled(wrapResultSets));
    }
    settings.setWrapResultSetsEnabled(wrapResultSets);

    boolean useGetGeneratedKeys =
        ConfigurationHelper.getBoolean(
            AvailableSettings.USE_GET_GENERATED_KEYS, properties, meta.supportsGetGeneratedKeys());
    if (debugEnabled) {
      LOG.debugf("JDBC3 getGeneratedKeys(): %s", enabledDisabled(useGetGeneratedKeys));
    }
    settings.setGetGeneratedKeysEnabled(useGetGeneratedKeys);

    Integer statementFetchSize =
        ConfigurationHelper.getInteger(AvailableSettings.STATEMENT_FETCH_SIZE, properties);
    if (statementFetchSize != null && debugEnabled) {
      LOG.debugf("JDBC result set fetch size: %s", statementFetchSize);
    }
    settings.setJdbcFetchSize(statementFetchSize);

    MultiTenancyStrategy multiTenancyStrategy =
        MultiTenancyStrategy.determineMultiTenancyStrategy(properties);
    if (debugEnabled) {
      LOG.debugf("multi-tenancy strategy : %s", multiTenancyStrategy);
    }
    settings.setMultiTenancyStrategy(multiTenancyStrategy);

    String releaseModeName =
        ConfigurationHelper.getString(AvailableSettings.RELEASE_CONNECTIONS, properties, "auto");
    if (debugEnabled) {
      LOG.debugf("Connection release mode: %s", releaseModeName);
    }
    ConnectionReleaseMode releaseMode;
    if ("auto".equals(releaseModeName)) {
      releaseMode = serviceRegistry.getService(TransactionFactory.class).getDefaultReleaseMode();
    } else {
      releaseMode = ConnectionReleaseMode.parse(releaseModeName);
      if (releaseMode == ConnectionReleaseMode.AFTER_STATEMENT) {
        // we need to make sure the underlying JDBC connection access supports aggressive release...
        boolean supportsAgrressiveRelease =
            multiTenancyStrategy.requiresMultiTenantConnectionProvider()
                ? serviceRegistry
                    .getService(MultiTenantConnectionProvider.class)
                    .supportsAggressiveRelease()
                : serviceRegistry.getService(ConnectionProvider.class).supportsAggressiveRelease();
        if (!supportsAgrressiveRelease) {
          LOG.unsupportedAfterStatement();
          releaseMode = ConnectionReleaseMode.AFTER_TRANSACTION;
        }
      }
    }
    settings.setConnectionReleaseMode(releaseMode);

    final BatchFetchStyle batchFetchStyle =
        BatchFetchStyle.interpret(properties.get(AvailableSettings.BATCH_FETCH_STYLE));
    LOG.debugf("Using BatchFetchStyle : " + batchFetchStyle.name());
    settings.setBatchFetchStyle(batchFetchStyle);

    // SQL Generation settings:

    String defaultSchema = properties.getProperty(AvailableSettings.DEFAULT_SCHEMA);
    String defaultCatalog = properties.getProperty(AvailableSettings.DEFAULT_CATALOG);
    if (defaultSchema != null && debugEnabled) {
      LOG.debugf("Default schema: %s", defaultSchema);
    }
    if (defaultCatalog != null && debugEnabled) {
      LOG.debugf("Default catalog: %s", defaultCatalog);
    }
    settings.setDefaultSchemaName(defaultSchema);
    settings.setDefaultCatalogName(defaultCatalog);

    Integer maxFetchDepth =
        ConfigurationHelper.getInteger(AvailableSettings.MAX_FETCH_DEPTH, properties);
    if (maxFetchDepth != null) {
      LOG.debugf("Maximum outer join fetch depth: %s", maxFetchDepth);
    }
    settings.setMaximumFetchDepth(maxFetchDepth);

    int batchFetchSize =
        ConfigurationHelper.getInt(AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, properties, 1);
    if (debugEnabled) {
      LOG.debugf("Default batch fetch size: %s", batchFetchSize);
    }
    settings.setDefaultBatchFetchSize(batchFetchSize);

    boolean comments =
        ConfigurationHelper.getBoolean(AvailableSettings.USE_SQL_COMMENTS, properties);
    if (debugEnabled) {
      LOG.debugf("Generate SQL with comments: %s", enabledDisabled(comments));
    }
    settings.setCommentsEnabled(comments);

    boolean orderUpdates =
        ConfigurationHelper.getBoolean(AvailableSettings.ORDER_UPDATES, properties);
    if (debugEnabled) {
      LOG.debugf("Order SQL updates by primary key: %s", enabledDisabled(orderUpdates));
    }
    settings.setOrderUpdatesEnabled(orderUpdates);

    boolean orderInserts =
        ConfigurationHelper.getBoolean(AvailableSettings.ORDER_INSERTS, properties);
    if (debugEnabled) {
      LOG.debugf("Order SQL inserts for batching: %s", enabledDisabled(orderInserts));
    }
    settings.setOrderInsertsEnabled(orderInserts);

    String defaultNullPrecedence =
        ConfigurationHelper.getString(
            AvailableSettings.DEFAULT_NULL_ORDERING, properties, "none", "first", "last");
    if (debugEnabled) {
      LOG.debugf("Default null ordering: %s", defaultNullPrecedence);
    }
    settings.setDefaultNullPrecedence(NullPrecedence.parse(defaultNullPrecedence));

    // Query parser settings:

    settings.setQueryTranslatorFactory(createQueryTranslatorFactory(properties, serviceRegistry));

    Map querySubstitutions =
        ConfigurationHelper.toMap(
            AvailableSettings.QUERY_SUBSTITUTIONS, " ,=;:\n\t\r\f", properties);
    if (debugEnabled) {
      LOG.debugf("Query language substitutions: %s", querySubstitutions);
    }
    settings.setQuerySubstitutions(querySubstitutions);

    boolean jpaqlCompliance =
        ConfigurationHelper.getBoolean(
            AvailableSettings.JPAQL_STRICT_COMPLIANCE, properties, false);
    if (debugEnabled) {
      LOG.debugf("JPA-QL strict compliance: %s", enabledDisabled(jpaqlCompliance));
    }
    settings.setStrictJPAQLCompliance(jpaqlCompliance);

    // Second-level / query cache:

    boolean useSecondLevelCache =
        ConfigurationHelper.getBoolean(AvailableSettings.USE_SECOND_LEVEL_CACHE, properties, true);
    if (debugEnabled) {
      LOG.debugf("Second-level cache: %s", enabledDisabled(useSecondLevelCache));
    }
    settings.setSecondLevelCacheEnabled(useSecondLevelCache);

    boolean useQueryCache =
        ConfigurationHelper.getBoolean(AvailableSettings.USE_QUERY_CACHE, properties);
    if (debugEnabled) {
      LOG.debugf("Query cache: %s", enabledDisabled(useQueryCache));
    }
    settings.setQueryCacheEnabled(useQueryCache);
    if (useQueryCache) {
      settings.setQueryCacheFactory(createQueryCacheFactory(properties, serviceRegistry));
    }

    // The cache provider is needed when we either have second-level cache enabled
    // or query cache enabled.  Note that useSecondLevelCache is enabled by default
    settings.setRegionFactory(
        createRegionFactory(properties, (useSecondLevelCache || useQueryCache), serviceRegistry));

    boolean useMinimalPuts =
        ConfigurationHelper.getBoolean(
            AvailableSettings.USE_MINIMAL_PUTS,
            properties,
            settings.getRegionFactory().isMinimalPutsEnabledByDefault());
    if (debugEnabled) {
      LOG.debugf("Optimize cache for minimal puts: %s", enabledDisabled(useMinimalPuts));
    }
    settings.setMinimalPutsEnabled(useMinimalPuts);

    String prefix = properties.getProperty(AvailableSettings.CACHE_REGION_PREFIX);
    if (StringHelper.isEmpty(prefix)) {
      prefix = null;
    }
    if (prefix != null && debugEnabled) {
      LOG.debugf("Cache region prefix: %s", prefix);
    }
    settings.setCacheRegionPrefix(prefix);

    boolean useStructuredCacheEntries =
        ConfigurationHelper.getBoolean(AvailableSettings.USE_STRUCTURED_CACHE, properties, false);
    if (debugEnabled) {
      LOG.debugf(
          "Structured second-level cache entries: %s", enabledDisabled(useStructuredCacheEntries));
    }
    settings.setStructuredCacheEntriesEnabled(useStructuredCacheEntries);

    boolean useDirectReferenceCacheEntries =
        ConfigurationHelper.getBoolean(
            AvailableSettings.USE_DIRECT_REFERENCE_CACHE_ENTRIES, properties, false);
    if (debugEnabled) {
      LOG.debugf(
          "Second-level cache direct-reference entries: %s",
          enabledDisabled(useDirectReferenceCacheEntries));
    }
    settings.setDirectReferenceCacheEntriesEnabled(useDirectReferenceCacheEntries);

    // Statistics and logging:

    boolean useStatistics =
        ConfigurationHelper.getBoolean(AvailableSettings.GENERATE_STATISTICS, properties);
    if (debugEnabled) {
      LOG.debugf("Statistics: %s", enabledDisabled(useStatistics));
    }
    settings.setStatisticsEnabled(useStatistics);

    boolean useIdentifierRollback =
        ConfigurationHelper.getBoolean(AvailableSettings.USE_IDENTIFIER_ROLLBACK, properties);
    if (debugEnabled) {
      LOG.debugf(
          "Deleted entity synthetic identifier rollback: %s",
          enabledDisabled(useIdentifierRollback));
    }
    settings.setIdentifierRollbackEnabled(useIdentifierRollback);

    // Schema export:

    String autoSchemaExport = properties.getProperty(AvailableSettings.HBM2DDL_AUTO);
    if ("validate".equals(autoSchemaExport)) {
      settings.setAutoValidateSchema(true);
    }
    if ("update".equals(autoSchemaExport)) {
      settings.setAutoUpdateSchema(true);
    }
    if ("create".equals(autoSchemaExport)) {
      settings.setAutoCreateSchema(true);
    }
    if ("create-drop".equals(autoSchemaExport)) {
      settings.setAutoCreateSchema(true);
      settings.setAutoDropSchema(true);
    }
    settings.setImportFiles(properties.getProperty(AvailableSettings.HBM2DDL_IMPORT_FILES));

    EntityMode defaultEntityMode =
        EntityMode.parse(properties.getProperty(AvailableSettings.DEFAULT_ENTITY_MODE));
    if (debugEnabled) {
      LOG.debugf("Default entity-mode: %s", defaultEntityMode);
    }
    settings.setDefaultEntityMode(defaultEntityMode);

    boolean namedQueryChecking =
        ConfigurationHelper.getBoolean(AvailableSettings.QUERY_STARTUP_CHECKING, properties, true);
    if (debugEnabled) {
      LOG.debugf("Named query checking : %s", enabledDisabled(namedQueryChecking));
    }
    settings.setNamedQueryStartupCheckingEnabled(namedQueryChecking);

    boolean checkNullability =
        ConfigurationHelper.getBoolean(AvailableSettings.CHECK_NULLABILITY, properties, true);
    if (debugEnabled) {
      LOG.debugf(
          "Check Nullability in Core (should be disabled when Bean Validation is on): %s",
          enabledDisabled(checkNullability));
    }
    settings.setCheckNullability(checkNullability);

    // TODO: Does EntityTuplizerFactory really need to be configurable? revisit for HHH-6383
    settings.setEntityTuplizerFactory(new EntityTuplizerFactory());

    //		String provider = properties.getProperty( AvailableSettings.BYTECODE_PROVIDER );
    //		log.info( "Bytecode provider name : " + provider );
    //		BytecodeProvider bytecodeProvider = buildBytecodeProvider( provider );
    //		settings.setBytecodeProvider( bytecodeProvider );

    boolean initializeLazyStateOutsideTransactionsEnabled =
        ConfigurationHelper.getBoolean(
            AvailableSettings.ENABLE_LAZY_LOAD_NO_TRANS, properties, false);
    if (debugEnabled) {
      LOG.debugf(
          "Allow initialization of lazy state outside session : : %s",
          enabledDisabled(initializeLazyStateOutsideTransactionsEnabled));
    }
    settings.setInitializeLazyStateOutsideTransactions(
        initializeLazyStateOutsideTransactionsEnabled);

    return settings;
  }
 public JavaTypeDescriptorRepositoryImpl(
     IndexView jandexIndex, ClassLoader jpaTempClassLoader, ServiceRegistry serviceRegistry) {
   this(jandexIndex, jpaTempClassLoader, serviceRegistry.getService(ClassLoaderService.class));
 }
 private static Type getType(String className, ServiceRegistry serviceRegistry) {
   return getType(serviceRegistry.getService(ClassLoaderService.class).classForName(className));
 }