Java 类org.hibernate.internal.util.config.ConfigurationHelper 实例源码

项目:lams    文件:Configuration.java   
/**
 * Create a {@link SessionFactory} using the properties and mappings in this configuration. The
 * {@link SessionFactory} will be immutable, so changes made to {@code this} {@link Configuration} after
 * building the {@link SessionFactory} will not affect it.
 *
 * @param serviceRegistry The registry of services to be used in creating this session factory.
 *
 * @return The built {@link SessionFactory}
 *
 * @throws HibernateException usually indicates an invalid configuration or invalid mapping information
 */
public SessionFactory buildSessionFactory(ServiceRegistry serviceRegistry) throws HibernateException {
    LOG.debugf( "Preparing to build session factory with filters : %s", filterDefinitions );

    buildTypeRegistrations( serviceRegistry );
    secondPassCompile();
    if ( !metadataSourceQueue.isEmpty() ) {
        LOG.incompleteMappingMetadataCacheProcessing();
    }

    validate();

    Environment.verifyProperties( properties );
    Properties copy = new Properties();
    copy.putAll( properties );
    ConfigurationHelper.resolvePlaceHolders( copy );
    Settings settings = buildSettings( copy, serviceRegistry );

    return new SessionFactoryImpl(
            this,
            mapping,
            serviceRegistry,
            settings,
            sessionFactoryObserver
        );
}
项目:lams    文件:TypeSafeActivator.java   
@SuppressWarnings({"unchecked", "UnusedParameters"})
private static void applyRelationalConstraints(ValidatorFactory factory, ActivationContext activationContext) {
    final Properties properties = activationContext.getConfiguration().getProperties();
    if ( ! ConfigurationHelper.getBoolean( BeanValidationIntegrator.APPLY_CONSTRAINTS, properties, true ) ){
        LOG.debug( "Skipping application of relational constraints from legacy Hibernate Validator" );
        return;
    }

    final Set<ValidationMode> modes = activationContext.getValidationModes();
    if ( ! ( modes.contains( ValidationMode.DDL ) || modes.contains( ValidationMode.AUTO ) ) ) {
        return;
    }

    applyRelationalConstraints(
            factory,
            activationContext.getConfiguration().createMappings().getClasses().values(),
            properties,
            activationContext.getServiceRegistry().getService( JdbcServices.class ).getDialect()
    );
}
项目:lams    文件:SchemaExport.java   
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 );
}
项目:lams    文件:SchemaExport.java   
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 );
}
项目:lams    文件:SchemaExport.java   
/**
 * Create a schema exporter for the given Configuration, with the given
 * database connection properties.
 *
 * @param configuration The configuration from which to build a schema export.
 * @param properties The properties from which to configure connectivity etc.
 * @throws HibernateException Indicates problem preparing for schema export.
 *
 * @deprecated properties may be specified via the Configuration object
 */
@Deprecated
   public SchemaExport(Configuration configuration, Properties properties) throws HibernateException {
    final Dialect dialect = Dialect.getDialect( properties );

    Properties props = new Properties();
    props.putAll( dialect.getDefaultProperties() );
    props.putAll( properties );
    this.connectionHelper = new ManagedProviderConnectionHelper( props );

    this.sqlStatementLogger = new SqlStatementLogger( false, true );
    this.formatter = FormatStyle.DDL.getFormatter();
    this.sqlExceptionHelper = new SqlExceptionHelper();

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

    this.dropSQL = configuration.generateDropSchemaScript( dialect );
    this.createSQL = configuration.generateSchemaCreationScript( dialect );
}
项目:lams    文件:SchemaExport.java   
/**
 * Create a schema exporter for the given Configuration, using the supplied connection for connectivity.
 *
 * @param configuration The configuration to use.
 * @param connection The JDBC connection to use.
 * @throws HibernateException Indicates problem preparing for schema export.
 */
public SchemaExport(Configuration configuration, Connection connection) throws HibernateException {
    this.connectionHelper = new SuppliedConnectionHelper( connection );

    this.sqlStatementLogger = new SqlStatementLogger( false, true );
    this.formatter = FormatStyle.DDL.getFormatter();
    this.sqlExceptionHelper = new SqlExceptionHelper();

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

    final Dialect dialect = Dialect.getDialect( configuration.getProperties() );
    this.dropSQL = configuration.generateDropSchemaScript( dialect );
    this.createSQL = configuration.generateSchemaCreationScript( dialect );
}
项目:lams    文件:BatchBuilderInitiator.java   
@Override
public BatchBuilder initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
    final Object builder = configurationValues.get( BUILDER );
    if ( builder == null ) {
        return new BatchBuilderImpl(
                ConfigurationHelper.getInt( Environment.STATEMENT_BATCH_SIZE, configurationValues, 1 )
        );
    }

    if ( BatchBuilder.class.isInstance( builder ) ) {
        return (BatchBuilder) builder;
    }

    final String builderClassName = builder.toString();
    try {
        return (BatchBuilder) registry.getService( ClassLoaderService.class ).classForName( builderClassName ).newInstance();
    }
    catch (Exception e) {
        throw new ServiceException( "Could not build explicit BatchBuilder [" + builderClassName + "]", e );
    }
}
项目:lams    文件:SequenceStyleGenerator.java   
/**
 * Determine the name of the sequence (or table if this resolves to a physical table)
 * to use.
 * <p/>
 * Called during {@link #configure configuration}.
 *
 * @param params The params supplied in the generator config (plus some standard useful extras).
 * @param dialect The dialect in effect
 * @return The sequence name
 */
protected String determineSequenceName(Properties params, Dialect dialect) {
    final String sequencePerEntitySuffix = ConfigurationHelper.getString( CONFIG_SEQUENCE_PER_ENTITY_SUFFIX, params, DEF_SEQUENCE_SUFFIX );
    // JPA_ENTITY_NAME value honors <class ... entity-name="..."> (HBM) and @Entity#name (JPA) overrides.
    String sequenceName = ConfigurationHelper.getBoolean( CONFIG_PREFER_SEQUENCE_PER_ENTITY, params, false )
            ? params.getProperty( JPA_ENTITY_NAME ) + sequencePerEntitySuffix
            : DEF_SEQUENCE_NAME;
    final ObjectNameNormalizer normalizer = (ObjectNameNormalizer) params.get( IDENTIFIER_NORMALIZER );
    sequenceName = ConfigurationHelper.getString( SEQUENCE_PARAM, params, sequenceName );
    if ( sequenceName.indexOf( '.' ) < 0 ) {
        sequenceName = normalizer.normalizeIdentifierQuoting( sequenceName );
        final String schemaName = params.getProperty( SCHEMA );
        final String catalogName = params.getProperty( CATALOG );
        sequenceName = Table.qualify(
                dialect.quote( catalogName ),
                dialect.quote( schemaName ),
                dialect.quote( sequenceName )
        );
    }
    // if already qualified there is not much we can do in a portable manner so we pass it
    // through and assume the user has set up the name correctly.

    return sequenceName;
}
项目:lams    文件:TableGenerator.java   
/**
 * Determine the table name to use for the generator values.
 * <p/>
 * Called during {@link #configure configuration}.
 *
 * @see #getTableName()
 * @param params The params supplied in the generator config (plus some standard useful extras).
 * @param dialect The dialect in effect
 * @return The table name to use.
 */
protected String determineGeneratorTableName(Properties params, Dialect dialect) {
    String name = ConfigurationHelper.getString( TABLE_PARAM, params, DEF_TABLE );
    final boolean isGivenNameUnqualified = name.indexOf( '.' ) < 0;
    if ( isGivenNameUnqualified ) {
        final ObjectNameNormalizer normalizer = (ObjectNameNormalizer) params.get( IDENTIFIER_NORMALIZER );
        name = normalizer.normalizeIdentifierQuoting( name );
        // if the given name is un-qualified we may neen to qualify it
        final String schemaName = normalizer.normalizeIdentifierQuoting( params.getProperty( SCHEMA ) );
        final String catalogName = normalizer.normalizeIdentifierQuoting( params.getProperty( CATALOG ) );
        name = Table.qualify(
                dialect.quote( catalogName ),
                dialect.quote( schemaName ),
                dialect.quote( name)
        );
    }
    // if already qualified there is not much we can do in a portable manner so we pass it
    // through and assume the user has set up the name correctly.

    return name;
}
项目:lams    文件:SequenceGenerator.java   
@Override
public void configure(Type type, Properties params, Dialect dialect) throws MappingException {
    ObjectNameNormalizer normalizer = ( ObjectNameNormalizer ) params.get( IDENTIFIER_NORMALIZER );
    sequenceName = normalizer.normalizeIdentifierQuoting(
            ConfigurationHelper.getString( SEQUENCE, params, "hibernate_sequence" )
    );
    parameters = params.getProperty( PARAMETERS );

    if ( sequenceName.indexOf( '.' ) < 0 ) {
        final String schemaName = normalizer.normalizeIdentifierQuoting( params.getProperty( SCHEMA ) );
        final String catalogName = normalizer.normalizeIdentifierQuoting( params.getProperty( CATALOG ) );
        sequenceName = Table.qualify(
                dialect.quote( catalogName ),
                dialect.quote( schemaName ),
                dialect.quote( sequenceName )
        );
    }
    else {
        // if already qualified there is not much we can do in a portable manner so we pass it
        // through and assume the user has set up the name correctly.
    }

    this.identifierType = type;
    sql = dialect.getSequenceNextValString( sequenceName );
}
项目:lams    文件:StandardServiceRegistryBuilder.java   
/**
 * Build the StandardServiceRegistry.
 *
 * @return The StandardServiceRegistry.
 */
@SuppressWarnings("unchecked")
public StandardServiceRegistry build() {
    final Map<?,?> settingsCopy = new HashMap();
    settingsCopy.putAll( settings );
    Environment.verifyProperties( settingsCopy );
    ConfigurationHelper.resolvePlaceHolders( settingsCopy );

    applyServiceContributingIntegrators();
    applyServiceContributors();

    return new StandardServiceRegistryImpl(
            autoCloseRegistry,
            bootstrapServiceRegistry,
            initiators,
            providedServices,
            settingsCopy
    );
}
项目:WatchWordBot    文件:Runner.java   
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Optional<SessionFactory> readSessionFactory() {
    Optional<SessionFactory> sessionFactory = Optional.empty();
    try {
        Configuration config = new Configuration().configure();
        final Map settingsCopy = new HashMap();
        settingsCopy.putAll(config.getProperties());
        ConfigurationHelper.resolvePlaceHolders(settingsCopy);
        for (Object o : settingsCopy.keySet()) {
            System.out.println("Hibernate property: " + o + "="
                    + settingsCopy.get(o));
        }

        sessionFactory = Optional.of(new Configuration().configure()
                .buildSessionFactory());
    } catch (Exception e) {
        System.err.println("Could not initialize database!");
        e.printStackTrace();
    }
    return sessionFactory;
}
项目:lams    文件:SettingsFactory.java   
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 );
    }
}
项目:lams    文件:SettingsFactory.java   
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 );
    }
}
项目:lams    文件:DatabaseMetadata.java   
public DatabaseMetadata(Connection connection, Dialect dialect, Configuration config, boolean extras)
        throws SQLException {
    sqlExceptionConverter = dialect.buildSQLExceptionConverter();
    meta = connection.getMetaData();
    this.extras = extras;
    initSequences( connection, dialect );
    if ( config != null
            && ConfigurationHelper.getBoolean( AvailableSettings.ENABLE_SYNONYMS, config.getProperties(), false ) ) {
        types = new String[] { "TABLE", "VIEW", "SYNONYM" };
    }
    else {
        types = new String[] { "TABLE", "VIEW" };
    }
}
项目:lams    文件:JmxServiceImpl.java   
public JmxServiceImpl(Map configValues) {
    usePlatformServer = ConfigurationHelper.getBoolean( AvailableSettings.JMX_PLATFORM_SERVER, configValues );
    agentId = (String) configValues.get( AvailableSettings.JMX_AGENT_ID );
    defaultDomain = (String) configValues.get( AvailableSettings.JMX_DOMAIN_NAME );
    sessionFactoryName = ConfigurationHelper.getString(
            AvailableSettings.JMX_SF_NAME,
            configValues,
            ConfigurationHelper.getString( Environment.SESSION_FACTORY_NAME, configValues )
    );
}
项目:lams    文件:AbstractJtaPlatform.java   
public void configure(Map configValues) {
    cacheTransactionManager = ConfigurationHelper.getBoolean(
            AvailableSettings.JTA_CACHE_TM,
            configValues,
            canCacheTransactionManagerByDefault()
    );
    cacheUserTransaction = ConfigurationHelper.getBoolean(
            AvailableSettings.JTA_CACHE_UT,
            configValues,
            canCacheUserTransactionByDefault()
    );
}
项目:lams    文件:QueryPlanCache.java   
/**
 * Constructs the QueryPlanCache to be used by the given SessionFactory
 *
 * @param factory The SessionFactory
 */
@SuppressWarnings("deprecation")
public QueryPlanCache(final SessionFactoryImplementor factory) {
    this.factory = factory;

    Integer maxParameterMetadataCount = ConfigurationHelper.getInteger(
            Environment.QUERY_PLAN_CACHE_PARAMETER_METADATA_MAX_SIZE,
            factory.getProperties()
    );
    if ( maxParameterMetadataCount == null ) {
        maxParameterMetadataCount = ConfigurationHelper.getInt(
                Environment.QUERY_PLAN_CACHE_MAX_STRONG_REFERENCES,
                factory.getProperties(),
                DEFAULT_PARAMETER_METADATA_MAX_COUNT
        );
    }
    Integer maxQueryPlanCount = ConfigurationHelper.getInteger(
            Environment.QUERY_PLAN_CACHE_MAX_SIZE,
            factory.getProperties()
    );
    if ( maxQueryPlanCount == null ) {
        maxQueryPlanCount = ConfigurationHelper.getInt(
                Environment.QUERY_PLAN_CACHE_MAX_SOFT_REFERENCES,
                factory.getProperties(),
                DEFAULT_QUERY_PLAN_MAX_COUNT
        );
    }

    queryPlanCache = new BoundedConcurrentHashMap( maxQueryPlanCount, 20, BoundedConcurrentHashMap.Eviction.LIRS );
    parameterMetadataCache = new BoundedConcurrentHashMap<String, ParameterMetadata>(
            maxParameterMetadataCount,
            20,
            BoundedConcurrentHashMap.Eviction.LIRS
    );

    nativeQueryInterpreterService = factory.getServiceRegistry().getService( NativeQueryInterpreter.class );
}
项目:lams    文件:DriverManagerConnectionProviderImpl.java   
private ConnectionCreator buildCreator(Map configurationValues) {
    final ConnectionCreatorBuilder connectionCreatorBuilder = new ConnectionCreatorBuilder( serviceRegistry );

    final String driverClassName = (String) configurationValues.get( AvailableSettings.DRIVER );
    connectionCreatorBuilder.setDriver( loadDriverIfPossible( driverClassName ) );

    final String url = (String) configurationValues.get( AvailableSettings.URL );
    if ( url == null ) {
        final String msg = log.jdbcUrlNotSpecified( AvailableSettings.URL );
        log.error( msg );
        throw new HibernateException( msg );
    }
    connectionCreatorBuilder.setUrl( url );

    log.usingDriver( driverClassName, url );

    final Properties connectionProps = ConnectionProviderInitiator.getConnectionProperties( configurationValues );

    // if debug level is enabled, then log the password, otherwise mask it
    if ( log.isDebugEnabled() ) {
        log.connectionProperties( connectionProps );
    }
    else {
        log.connectionProperties( ConfigurationHelper.maskOut( connectionProps, "password" ) );
    }
    connectionCreatorBuilder.setConnectionProps( connectionProps );

    final boolean autoCommit = ConfigurationHelper.getBoolean( AvailableSettings.AUTOCOMMIT, configurationValues, false );
    log.autoCommitMode( autoCommit );
    connectionCreatorBuilder.setAutoCommit( autoCommit );

    final Integer isolation = ConfigurationHelper.getInteger( AvailableSettings.ISOLATION, configurationValues );
    if ( isolation != null ) {
        log.jdbcIsolationLevel( Environment.isolationLevelToString( isolation ) );
    }
    connectionCreatorBuilder.setIsolation( isolation );

    return connectionCreatorBuilder.build();
}
项目:lams    文件:AbstractServiceRegistryImpl.java   
protected AbstractServiceRegistryImpl(
        ServiceRegistryImplementor parent,
        boolean autoCloseRegistry) {
    this.parent = parent;
    this.allowCrawling = ConfigurationHelper.getBoolean( ALLOW_CRAWLING, Environment.getProperties(), true );

    this.autoCloseRegistry = autoCloseRegistry;
    this.parent.registerChild( this );
}
项目:lams    文件:AbstractServiceRegistryImpl.java   
public AbstractServiceRegistryImpl(
        BootstrapServiceRegistry bootstrapServiceRegistry,
        boolean autoCloseRegistry) {
    if ( ! ServiceRegistryImplementor.class.isInstance( bootstrapServiceRegistry ) ) {
        throw new IllegalArgumentException( "ServiceRegistry parent needs to implement ServiceRegistryImplementor" );
    }
    this.parent = (ServiceRegistryImplementor) bootstrapServiceRegistry;
    this.allowCrawling = ConfigurationHelper.getBoolean( ALLOW_CRAWLING, Environment.getProperties(), true );

    this.autoCloseRegistry = autoCloseRegistry;
    this.parent.registerChild( this );
}
项目:lams    文件:SequenceStyleGenerator.java   
@Override
public void configure(Type type, Properties params, Dialect dialect) throws MappingException {
    this.identifierType = type;
    boolean forceTableUse = ConfigurationHelper.getBoolean( FORCE_TBL_PARAM, params, false );

    final String sequenceName = determineSequenceName( params, dialect );

    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,
            dialect,
            forceTableUse,
            sequenceName,
            initialValue,
            incrementSize
    );
    this.optimizer = OptimizerFactory.buildOptimizer(
            optimizationStrategy,
            identifierType.getReturnedClass(),
            incrementSize,
            ConfigurationHelper.getInt( INITIAL_PARAM, params, -1 )
    );
    this.databaseStructure.prepare( optimizer );
}
项目:lams    文件:SequenceStyleGenerator.java   
/**
 * Determine the optimizer to use.
 * <p/>
 * Called during {@link #configure configuration}.
 *
 * @param params The params supplied in the generator config (plus some standard useful extras).
 * @param incrementSize The {@link #determineIncrementSize determined increment size}
 * @return The optimizer strategy (name)
 */
protected String determineOptimizationStrategy(Properties params, int incrementSize) {
    // if the increment size is greater than one, we prefer pooled optimization; but we first
    // need to see if the user prefers POOL or POOL_LO...
    final String defaultPooledOptimizerStrategy = ConfigurationHelper.getBoolean( Environment.PREFER_POOLED_VALUES_LO, params, false )
            ? StandardOptimizerDescriptor.POOLED_LO.getExternalName()
            : StandardOptimizerDescriptor.POOLED.getExternalName();
    final String defaultOptimizerStrategy = incrementSize <= 1
            ? StandardOptimizerDescriptor.NONE.getExternalName()
            : defaultPooledOptimizerStrategy;
    return ConfigurationHelper.getString( OPT_PARAM, params, defaultOptimizerStrategy );
}
项目:lams    文件:TableGenerator.java   
@Override
public void configure(Type type, Properties params, Dialect dialect) throws MappingException {
    identifierType = type;

    tableName = determineGeneratorTableName( params, dialect );
    segmentColumnName = determineSegmentColumnName( params, dialect );
    valueColumnName = determineValueColumnName( params, dialect );

    segmentValue = determineSegmentValue( params );

    segmentValueLength = determineSegmentColumnSize( params );
    initialValue = determineInitialValue( params );
    incrementSize = determineIncrementSize( params );

    this.selectQuery = buildSelectQuery( dialect );
    this.updateQuery = buildUpdateQuery();
    this.insertQuery = buildInsertQuery();

    // if the increment size is greater than one, we prefer pooled optimization; but we
    // need to see if the user prefers POOL or POOL_LO...
    final String defaultPooledOptimizerStrategy = ConfigurationHelper.getBoolean( Environment.PREFER_POOLED_VALUES_LO, params, false )
            ? StandardOptimizerDescriptor.POOLED_LO.getExternalName()
            : StandardOptimizerDescriptor.POOLED.getExternalName();
    final String defaultOptimizerStrategy = incrementSize <= 1
            ? StandardOptimizerDescriptor.NONE.getExternalName()
            : defaultPooledOptimizerStrategy;
    final String optimizationStrategy = ConfigurationHelper.getString( OPT_PARAM, params, defaultOptimizerStrategy );
    optimizer = OptimizerFactory.buildOptimizer(
            optimizationStrategy,
            identifierType.getReturnedClass(),
            incrementSize,
            ConfigurationHelper.getInt( INITIAL_PARAM, params, -1 )
    );
}
项目:lams    文件:TableGenerator.java   
public void configure(Type type, Properties params, Dialect dialect) {
    identifierType = type;

    ObjectNameNormalizer normalizer = ( ObjectNameNormalizer ) params.get( IDENTIFIER_NORMALIZER );

    tableName = ConfigurationHelper.getString( TABLE, params, DEFAULT_TABLE_NAME );
    if ( tableName.indexOf( '.' ) < 0 ) {
        final String schemaName = normalizer.normalizeIdentifierQuoting( params.getProperty( SCHEMA ) );
        final String catalogName = normalizer.normalizeIdentifierQuoting( params.getProperty( CATALOG ) );
        tableName = Table.qualify(
                dialect.quote( catalogName ),
                dialect.quote( schemaName ),
                dialect.quote( tableName )
        );
    }
    else {
        // if already qualified there is not much we can do in a portable manner so we pass it
        // through and assume the user has set up the name correctly.
    }

    columnName = dialect.quote(
            normalizer.normalizeIdentifierQuoting(
                    ConfigurationHelper.getString( COLUMN, params, DEFAULT_COLUMN_NAME )
            )
    );

    query = "select " +
        columnName +
        " from " +
        dialect.appendLockHint(LockMode.PESSIMISTIC_WRITE, tableName) +
        dialect.getForUpdateString();

    update = "update " +
        tableName +
        " set " +
        columnName +
        " = ? where " +
        columnName +
        " = ?";
}
项目:lams    文件:SequenceHiLoGenerator.java   
public void configure(Type type, Properties params, Dialect d) throws MappingException {
    super.configure(type, params, d);

    maxLo = ConfigurationHelper.getInt( MAX_LO, params, 9 );

    if ( maxLo >= 1 ) {
        hiloOptimizer = new LegacyHiLoAlgorithmOptimizer(
                getIdentifierType().getReturnedClass(),
                maxLo
        );
    }
}
项目:lams    文件:TableHiLoGenerator.java   
@Override
public void configure(Type type, Properties params, Dialect d) {
    super.configure( type, params, d );
    maxLo = ConfigurationHelper.getInt( MAX_LO, params, Short.MAX_VALUE );

    if ( maxLo >= 1 ) {
        hiloOptimizer = new LegacyHiLoAlgorithmOptimizer( type.getReturnedClass(), maxLo );
    }
}
项目:lams    文件:PersistentTableBulkIdStrategy.java   
@Override
public void prepare(
        JdbcServices jdbcServices,
        JdbcConnectionAccess connectionAccess,
        Mappings mappings,
        Mapping mapping,
        Map settings) {
    this.catalog = ConfigurationHelper.getString(
            CATALOG,
            settings,
            ConfigurationHelper.getString( AvailableSettings.DEFAULT_CATALOG, settings )
    );
    this.schema = ConfigurationHelper.getString(
            SCHEMA,
            settings,
            ConfigurationHelper.getString( AvailableSettings.DEFAULT_SCHEMA, settings )
    );
    this.cleanUpTables = ConfigurationHelper.getBoolean( CLEAN_UP_ID_TABLES, settings, false );

    final Iterator<PersistentClass> entityMappings = mappings.iterateClasses();
    final List<Table> idTableDefinitions = new ArrayList<Table>();
    while ( entityMappings.hasNext() ) {
        final PersistentClass entityMapping = entityMappings.next();
        final Table idTableDefinition = generateIdTableDefinition( entityMapping );
        idTableDefinitions.add( idTableDefinition );
    }
    exportTableDefinitions( idTableDefinitions, jdbcServices, connectionAccess, mappings, mapping );
}
项目:bootstrap    文件:SequenceIdentifierGeneratorStrategyProvider.java   
@Override
protected QualifiedName determineSequenceName(final Properties params, final Dialect dialect, final JdbcEnvironment jdbcEnv) {
    // Make sure sequence are lower case and corresponds to table name
    params.put(SEQUENCE_PARAM, StringHelper.unquote(params.getProperty("identity_tables"))
            + ConfigurationHelper.getString(CONFIG_SEQUENCE_PER_ENTITY_SUFFIX, params, DEF_SEQUENCE_SUFFIX));
    return super.determineSequenceName(params, dialect, jdbcEnv);
}
项目:hazelcast-hibernate5    文件:CacheEnvironment.java   
public static String getConfigFilePath(final Properties props) {
    String configResourcePath = ConfigurationHelper.getString(CacheEnvironment.CONFIG_FILE_PATH_LEGACY, props, null);
    if (StringHelper.isEmpty(configResourcePath)) {
        configResourcePath = ConfigurationHelper.getString(CacheEnvironment.CONFIG_FILE_PATH, props, null);
    }
    return configResourcePath;
}
项目:hazelcast-hibernate5    文件:CacheEnvironment.java   
public static int getLockTimeoutInMillis(final Properties props) {
    int timeout = -1;
    try {
        timeout = ConfigurationHelper.getInt(LOCK_TIMEOUT, props, -1);
    } catch (Exception e) {
        Logger.getLogger(CacheEnvironment.class).finest(e);
    }
    if (timeout < 0) {
        timeout = MAXIMUM_LOCK_TIMEOUT;
    }
    return timeout;
}
项目:cibet    文件:CibetIntegrator.java   
@Override
public void integrate(Configuration configuration, SessionFactoryImplementor sessionFactory,
      SessionFactoryServiceRegistry serviceRegistry) {
   log.info("start CibetIntegrator");
   final boolean autoRegister = ConfigurationHelper.getBoolean(AUTO_REGISTER, configuration.getProperties(), true);
   if (autoRegister) {
      log.debug("Skipping Cibet Envers listener auto registration");
      return;
   }

   log.info("CibetIntegrator registers Cibet Envers listeners");

   EventListenerRegistry listenerRegistry = serviceRegistry.getService(EventListenerRegistry.class);
   listenerRegistry.addDuplicationStrategy(EnversListenerDuplicationStrategy.INSTANCE);

   enversConfiguration = AuditConfiguration.getFor(configuration,
         serviceRegistry.getService(ClassLoaderService.class));

   if (enversConfiguration.getEntCfg().hasAuditedEntities()) {
      listenerRegistry.appendListeners(EventType.POST_DELETE, new CibetPostDeleteEventListener(enversConfiguration));
      listenerRegistry.appendListeners(EventType.POST_INSERT, new CibetPostInsertEventListener(enversConfiguration));
      listenerRegistry.appendListeners(EventType.POST_UPDATE, new CibetPostUpdateEventListener(enversConfiguration));
      listenerRegistry.appendListeners(EventType.POST_COLLECTION_RECREATE,
            new CibetPostCollectionRecreateEventListener(enversConfiguration));
      listenerRegistry.appendListeners(EventType.PRE_COLLECTION_REMOVE,
            new CibetPreCollectionRemoveEventListener(enversConfiguration));
      listenerRegistry.appendListeners(EventType.PRE_COLLECTION_UPDATE,
            new CibetPreCollectionUpdateEventListener(enversConfiguration));
   }
}
项目:hazelcast-hibernate    文件:CacheEnvironment.java   
public static String getConfigFilePath(Properties props) {
    String configResourcePath = ConfigurationHelper.getString(CacheEnvironment.CONFIG_FILE_PATH_LEGACY, props, null);
    if (StringHelper.isEmpty(configResourcePath)) {
        configResourcePath = ConfigurationHelper.getString(CacheEnvironment.CONFIG_FILE_PATH, props, null);
    }
    return configResourcePath;
}
项目:hazelcast-hibernate    文件:CacheEnvironment.java   
public static int getLockTimeoutInMillis(Properties props) {
    int timeout = -1;
    try {
        timeout = ConfigurationHelper.getInt(LOCK_TIMEOUT, props, -1);
    } catch (Exception e) {
        Logger.getLogger(CacheEnvironment.class).finest(e);
    }
    if (timeout < 0) {
        timeout = MAXIMUM_LOCK_TIMEOUT;
    }
    return timeout;
}
项目:owsi-core-parent    文件:PerTableSequenceStyleGenerator.java   
@Override
protected QualifiedName determineSequenceName(Properties params, Dialect dialect, JdbcEnvironment jdbcEnv) {
    String tableName = params.getProperty(PersistentIdentifierGenerator.TABLE);
    String columnName = params.getProperty(PersistentIdentifierGenerator.PK);

    if (tableName != null && columnName != null) {
        StringBuilder sequenceNameBuilder = new StringBuilder();

        sequenceNameBuilder.append(tableName);
        sequenceNameBuilder.append(SEQUENCE_NAME_SEPARATOR);
        sequenceNameBuilder.append(columnName);
        sequenceNameBuilder.append(SEQUENCE_NAME_SEPARATOR);
        sequenceNameBuilder.append(SEQUENCE_NAME_SUFFIX);

        // todo : need to incorporate implicit catalog and schema names
        final Identifier catalog = jdbcEnv.getIdentifierHelper().toIdentifier(
                ConfigurationHelper.getString( CATALOG, params )
        );
        final Identifier schema =  jdbcEnv.getIdentifierHelper().toIdentifier(
                ConfigurationHelper.getString( SCHEMA, params )
        );
        return new QualifiedNameParser.NameParts(
                catalog,
                schema,
                jdbcEnv.getIdentifierHelper().toIdentifier( sequenceNameBuilder.toString() )
        );
    }
    throw new IllegalStateException("Unable to build the sequence name");
}
项目:high-performance-java-persistence    文件:StringSequenceIdentifier.java   
@Override
public void configure(
        Type type, Properties params, ServiceRegistry serviceRegistry)
        throws MappingException {
    final JdbcEnvironment jdbcEnvironment =
            serviceRegistry.getService(JdbcEnvironment.class);
    final Dialect dialect = jdbcEnvironment.getDialect();

    final ConfigurationService configurationService =
            serviceRegistry.getService(ConfigurationService.class);
    String globalEntityIdentifierPrefix =
        configurationService.getSetting( "entity.identifier.prefix", String.class, "SEQ_" );

    sequencePrefix = ConfigurationHelper.getString(
            SEQUENCE_PREFIX,
            params,
            globalEntityIdentifierPrefix);

    final String sequencePerEntitySuffix = ConfigurationHelper.getString(
            SequenceStyleGenerator.CONFIG_SEQUENCE_PER_ENTITY_SUFFIX,
            params,
            SequenceStyleGenerator.DEF_SEQUENCE_SUFFIX);

    final String defaultSequenceName = ConfigurationHelper.getBoolean(
            SequenceStyleGenerator.CONFIG_PREFER_SEQUENCE_PER_ENTITY,
            params,
            false)
            ? params.getProperty(JPA_ENTITY_NAME) + sequencePerEntitySuffix
            : SequenceStyleGenerator.DEF_SEQUENCE_NAME;

    sequenceCallSyntax = dialect.getSequenceNextValString(
            ConfigurationHelper.getString(
                    SequenceStyleGenerator.SEQUENCE_PARAM,
                    params,
                    defaultSequenceName));
}
项目:jeffaschenk-commons    文件:PlatformSequenceGenerator.java   
/**
 * {@inheritDoc}
 * <p/>
 * Configuration of the Sequence Mapping.
 */
@Override
public void configure(Type type, Properties params, Dialect dialect)
        throws MappingException {
    this.dialect = dialect;
    // This is only used during Database creation, which is only used in test
    String table = ConfigurationHelper.getString("target_table", params, "TABLE");
    sequenceName = table + "_seq_id";
}
项目:lams    文件:Environment.java   
public static BytecodeProvider buildBytecodeProvider(Properties properties) {
    String provider = ConfigurationHelper.getString( BYTECODE_PROVIDER, properties, "javassist" );
    LOG.bytecodeProvider( provider );
    return buildBytecodeProvider( provider );
}
项目:lams    文件:SchemaExport.java   
private static StandardServiceRegistryImpl createServiceRegistry(Properties properties) {
    Environment.verifyProperties( properties );
    ConfigurationHelper.resolvePlaceHolders( properties );
    return (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().applySettings( properties ).build();
}
项目:lams    文件:ManagedProviderConnectionHelper.java   
private static StandardServiceRegistryImpl createServiceRegistry(Properties properties) {
    Environment.verifyProperties( properties );
    ConfigurationHelper.resolvePlaceHolders( properties );
    return (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().applySettings( properties ).build();
}