org.hibernate.internal.util.config.ConfigurationHelper Java Examples
The following examples show how to use
org.hibernate.internal.util.config.ConfigurationHelper.
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: ReactiveServiceRegistryBuilder.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 6 votes |
/** * Build the StandardServiceRegistry. * * @return The StandardServiceRegistry. */ @SuppressWarnings("unchecked") public StandardServiceRegistry build() { applyServiceContributingIntegrators(); applyServiceContributors(); @SuppressWarnings("rawtypes") final Map settingsCopy = new HashMap( settings ); settingsCopy.put( org.hibernate.boot.cfgxml.spi.CfgXmlAccessService.LOADED_CONFIG_KEY, aggregatedCfgXml ); ConfigurationHelper.resolvePlaceHolders( settingsCopy ); return new StandardServiceRegistryImpl( autoCloseRegistry, bootstrapServiceRegistry, initiators, providedServices, settingsCopy ); }
Example #2
Source File: DriverManagerConnectionProviderImpl.java From lams with GNU General Public License v2.0 | 6 votes |
private PooledConnections buildPool(Map configurationValues) { final boolean autoCommit = ConfigurationHelper.getBoolean( AvailableSettings.AUTOCOMMIT, configurationValues, false ); final int minSize = ConfigurationHelper.getInt( MIN_SIZE, configurationValues, 1 ); final int maxSize = ConfigurationHelper.getInt( AvailableSettings.POOL_SIZE, configurationValues, 20 ); final int initialSize = ConfigurationHelper.getInt( INITIAL_SIZE, configurationValues, minSize ); ConnectionCreator connectionCreator = buildCreator( configurationValues ); PooledConnections.Builder pooledConnectionBuilder = new PooledConnections.Builder( connectionCreator, autoCommit ); pooledConnectionBuilder.initialSize( initialSize ); pooledConnectionBuilder.minSize( minSize ); pooledConnectionBuilder.maxSize( maxSize ); return pooledConnectionBuilder.build(); }
Example #3
Source File: DriverManagerConnectionProviderImpl.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public void configure(Map configurationValues) { log.usingHibernateBuiltInConnectionPool(); pool = buildPool( configurationValues ); final long validationInterval = ConfigurationHelper.getLong( VALIDATION_INTERVAL, configurationValues, 30 ); executorService = Executors.newSingleThreadScheduledExecutor(); executorService.scheduleWithFixedDelay( new Runnable() { private boolean primed; @Override public void run() { pool.validate(); } }, validationInterval, validationInterval, TimeUnit.SECONDS ); }
Example #4
Source File: BatchBuilderInitiator.java From lams with GNU General Public License v2.0 | 6 votes |
@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 ); } }
Example #5
Source File: SequenceGenerator.java From lams with GNU General Public License v2.0 | 6 votes |
@Override @SuppressWarnings("StatementWithEmptyBody") public void configure(Type type, Properties params, ServiceRegistry serviceRegistry) throws MappingException { DeprecationLogger.DEPRECATION_LOGGER.deprecatedSequenceGenerator( getClass().getName() ); identifierType = type; final ObjectNameNormalizer normalizer = (ObjectNameNormalizer) params.get( IDENTIFIER_NORMALIZER ); logicalQualifiedSequenceName = QualifiedNameParser.INSTANCE.parse( ConfigurationHelper.getString( SEQUENCE, params, "hibernate_sequence" ), normalizer.normalizeIdentifierQuoting( params.getProperty( CATALOG ) ), normalizer.normalizeIdentifierQuoting( params.getProperty( SCHEMA ) ) ); if ( params.containsKey( PARAMETERS ) ) { LOG.warn( "Use of 'parameters' config setting is no longer supported; " + "to specify initial-value or increment use the " + "org.hibernate.id.enhanced.SequenceStyleGenerator generator instead." ); } }
Example #6
Source File: QuarkusRegionFactoryInitiator.java From quarkus with Apache License 2.0 | 6 votes |
@Override public RegionFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) { final Boolean useSecondLevelCache = ConfigurationHelper.getBooleanWrapper( AvailableSettings.USE_SECOND_LEVEL_CACHE, configurationValues, Boolean.TRUE); final Boolean useQueryCache = ConfigurationHelper.getBooleanWrapper( AvailableSettings.USE_QUERY_CACHE, configurationValues, Boolean.TRUE); // We should immediately return NoCachingRegionFactory if either: // 1) both are explicitly FALSE // 2) USE_SECOND_LEVEL_CACHE is FALSE and USE_QUERY_CACHE is null if (useSecondLevelCache != null && useSecondLevelCache == FALSE) { if (useQueryCache == null || useQueryCache == FALSE) { return NoCachingRegionFactory.INSTANCE; } } return new QuarkusInfinispanRegionFactory(); }
Example #7
Source File: MultipleHiLoPerTableGenerator.java From lams with GNU General Public License v2.0 | 6 votes |
protected QualifiedName determineGeneratorTableName(Properties params, JdbcEnvironment jdbcEnvironment) { final String tableName = ConfigurationHelper.getString( ID_TABLE, params, DEFAULT_TABLE ); if ( tableName.contains( "." ) ) { return QualifiedNameParser.INSTANCE.parse( tableName ); } else { // todo : need to incorporate implicit catalog and schema names final Identifier catalog = jdbcEnvironment.getIdentifierHelper().toIdentifier( ConfigurationHelper.getString( CATALOG, params ) ); final Identifier schema = jdbcEnvironment.getIdentifierHelper().toIdentifier( ConfigurationHelper.getString( SCHEMA, params ) ); return new QualifiedNameParser.NameParts( catalog, schema, jdbcEnvironment.getIdentifierHelper().toIdentifier( tableName ) ); } }
Example #8
Source File: StandardServiceRegistryBuilder.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Build the StandardServiceRegistry. * * @return The StandardServiceRegistry. */ @SuppressWarnings("unchecked") public StandardServiceRegistry build() { applyServiceContributingIntegrators(); applyServiceContributors(); final Map settingsCopy = new HashMap(); settingsCopy.putAll( settings ); settingsCopy.put( org.hibernate.boot.cfgxml.spi.CfgXmlAccessService.LOADED_CONFIG_KEY, aggregatedCfgXml ); Environment.verifyProperties( settingsCopy ); ConfigurationHelper.resolvePlaceHolders( settingsCopy ); return new StandardServiceRegistryImpl( autoCloseRegistry, bootstrapServiceRegistry, initiators, providedServices, settingsCopy ); }
Example #9
Source File: MultipleHiLoPerTableGenerator.java From lams with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings({"StatementWithEmptyBody", "deprecation"}) public void configure(Type type, Properties params, ServiceRegistry serviceRegistry) throws MappingException { returnClass = type.getReturnedClass(); final JdbcEnvironment jdbcEnvironment = serviceRegistry.getService( JdbcEnvironment.class ); qualifiedTableName = determineGeneratorTableName( params, jdbcEnvironment ); segmentColumnName = determineSegmentColumnName( params, jdbcEnvironment ); keySize = ConfigurationHelper.getInt( PK_LENGTH_NAME, params, DEFAULT_PK_LENGTH ); segmentName = ConfigurationHelper.getString( PK_VALUE_NAME, params, params.getProperty( TABLE ) ); valueColumnName = determineValueColumnName( params, jdbcEnvironment ); //hilo config maxLo = ConfigurationHelper.getInt( MAX_LO, params, Short.MAX_VALUE ); if ( maxLo >= 1 ) { hiloOptimizer = new LegacyHiLoAlgorithmOptimizer( returnClass, maxLo ); } }
Example #10
Source File: OptimizerFactory.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Determine the optimizer to use when there was not one explicitly specified. */ public static String determineImplicitOptimizerName(int incrementSize, Properties configSettings) { if ( incrementSize <= 1 ) { return StandardOptimizerDescriptor.NONE.getExternalName(); } // see if the user defined a preferred pooled optimizer... final String preferredPooledOptimizerStrategy = configSettings.getProperty( AvailableSettings.PREFERRED_POOLED_OPTIMIZER ); if ( StringHelper.isNotEmpty( preferredPooledOptimizerStrategy ) ) { return preferredPooledOptimizerStrategy; } // otherwise fallback to the fallback strategy (considering the deprecated PREFER_POOLED_VALUES_LO setting) return ConfigurationHelper.getBoolean( AvailableSettings.PREFER_POOLED_VALUES_LO, configSettings, false ) ? StandardOptimizerDescriptor.POOLED_LO.getExternalName() : StandardOptimizerDescriptor.POOLED.getExternalName(); }
Example #11
Source File: RedissonRegionFactory.java From redisson with Apache License 2.0 | 6 votes |
protected RedissonClient createRedissonClient(Properties properties) { Config config = null; if (!properties.containsKey(REDISSON_CONFIG_PATH)) { config = loadConfig(RedissonRegionFactory.class.getClassLoader(), "redisson.json"); if (config == null) { config = loadConfig(RedissonRegionFactory.class.getClassLoader(), "redisson.yaml"); } } else { String configPath = ConfigurationHelper.getString(REDISSON_CONFIG_PATH, properties); config = loadConfig(RedissonRegionFactory.class.getClassLoader(), configPath); if (config == null) { config = loadConfig(configPath); } } if (config == null) { throw new CacheException("Unable to locate Redisson configuration"); } return Redisson.create(config); }
Example #12
Source File: RedissonRegionFactory.java From redisson with Apache License 2.0 | 6 votes |
protected RedissonClient createRedissonClient(Properties properties) { Config config = null; if (!properties.containsKey(REDISSON_CONFIG_PATH)) { config = loadConfig(RedissonRegionFactory.class.getClassLoader(), "redisson.json"); if (config == null) { config = loadConfig(RedissonRegionFactory.class.getClassLoader(), "redisson.yaml"); } } else { String configPath = ConfigurationHelper.getString(REDISSON_CONFIG_PATH, properties); config = loadConfig(RedissonRegionFactory.class.getClassLoader(), configPath); if (config == null) { config = loadConfig(configPath); } } if (config == null) { throw new CacheException("Unable to locate Redisson configuration"); } return Redisson.create(config); }
Example #13
Source File: RedissonRegionFactory.java From redisson with Apache License 2.0 | 6 votes |
protected RedissonClient createRedissonClient(Map properties) { Config config = null; if (!properties.containsKey(REDISSON_CONFIG_PATH)) { config = loadConfig(RedissonRegionFactory.class.getClassLoader(), "redisson.json"); if (config == null) { config = loadConfig(RedissonRegionFactory.class.getClassLoader(), "redisson.yaml"); } } else { String configPath = ConfigurationHelper.getString(REDISSON_CONFIG_PATH, properties); config = loadConfig(RedissonRegionFactory.class.getClassLoader(), configPath); if (config == null) { config = loadConfig(configPath); } } if (config == null) { throw new CacheException("Unable to locate Redisson configuration"); } String fallbackValue = (String) properties.getOrDefault(FALLBACK, "false"); fallback = Boolean.valueOf(fallbackValue); return Redisson.create(config); }
Example #14
Source File: RedissonRegionFactory.java From redisson with Apache License 2.0 | 6 votes |
protected RedissonClient createRedissonClient(Properties properties) { Config config = null; if (!properties.containsKey(REDISSON_CONFIG_PATH)) { config = loadConfig(RedissonRegionFactory.class.getClassLoader(), "redisson.json"); if (config == null) { config = loadConfig(RedissonRegionFactory.class.getClassLoader(), "redisson.yaml"); } } else { String configPath = ConfigurationHelper.getString(REDISSON_CONFIG_PATH, properties); config = loadConfig(RedissonRegionFactory.class.getClassLoader(), configPath); if (config == null) { config = loadConfig(configPath); } } if (config == null) { throw new CacheException("Unable to locate Redisson configuration"); } return Redisson.create(config); }
Example #15
Source File: AbstractServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 5 votes |
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 ); }
Example #16
Source File: DisabledJMXInitiator.java From quarkus with Apache License 2.0 | 5 votes |
@Override public JmxService initiateService(Map configurationValues, ServiceRegistryImplementor registry) { if (ConfigurationHelper.getBoolean(AvailableSettings.JMX_ENABLED, configurationValues, false)) { Logger.getLogger(DisabledJMXInitiator.class) .warn("Enabling JMX is not allowed in Quarkus: forcefully disabled. Ignoring property:" + AvailableSettings.JMX_ENABLED); } return DisabledJmxServiceImpl.INSTANCE; }
Example #17
Source File: MutableJpaComplianceImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("ConstantConditions") public MutableJpaComplianceImpl(Map configurationSettings, boolean jpaByDefault) { final Object legacyQueryCompliance = configurationSettings.get( AvailableSettings.JPAQL_STRICT_COMPLIANCE ); queryCompliance = ConfigurationHelper.getBoolean( AvailableSettings.JPA_QUERY_COMPLIANCE, configurationSettings, ConfigurationHelper.toBoolean( legacyQueryCompliance, jpaByDefault ) ); transactionCompliance = ConfigurationHelper.getBoolean( AvailableSettings.JPA_TRANSACTION_COMPLIANCE, configurationSettings, jpaByDefault ); listCompliance = ConfigurationHelper.getBoolean( AvailableSettings.JPA_LIST_COMPLIANCE, configurationSettings, jpaByDefault ); closedCompliance = ConfigurationHelper.getBoolean( AvailableSettings.JPA_CLOSED_COMPLIANCE, configurationSettings, jpaByDefault ); proxyCompliance = ConfigurationHelper.getBoolean( AvailableSettings.JPA_PROXY_COMPLIANCE, configurationSettings, jpaByDefault ); cachingCompliance = ConfigurationHelper.getBoolean( AvailableSettings.JPA_CACHING_COMPLIANCE, configurationSettings, jpaByDefault ); globalGeneratorNameScopeCompliance = ConfigurationHelper.getBoolean( AvailableSettings.JPA_ID_GENERATOR_GLOBAL_SCOPE_COMPLIANCE, configurationSettings, jpaByDefault ); }
Example #18
Source File: AbstractJtaPlatform.java From lams with GNU General Public License v2.0 | 5 votes |
public void configure(Map configValues) { cacheTransactionManager = ConfigurationHelper.getBoolean( AvailableSettings.JTA_CACHE_TM, configValues, canCacheTransactionManagerByDefault() ); cacheUserTransaction = ConfigurationHelper.getBoolean( AvailableSettings.JTA_CACHE_UT, configValues, canCacheUserTransactionByDefault() ); }
Example #19
Source File: BaseCoreFunctionalTestCase.java From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 | 5 votes |
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 #20
Source File: QueryPlanCache.java From lams with GNU General Public License v2.0 | 5 votes |
/** * 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<>( maxParameterMetadataCount, 20, BoundedConcurrentHashMap.Eviction.LIRS ); nativeQueryInterpreter = factory.getServiceRegistry().getService( NativeQueryInterpreter.class ); }
Example #21
Source File: EnumType.java From lams with GNU General Public License v2.0 | 5 votes |
private EnumValueConverter interpretParameters(Properties parameters) { final EnumJavaTypeDescriptor javaTypeDescriptor = (EnumJavaTypeDescriptor) typeConfiguration .getJavaTypeDescriptorRegistry() .getDescriptor( enumClass ); if ( parameters.containsKey( NAMED ) ) { final boolean useNamed = ConfigurationHelper.getBoolean( NAMED, parameters ); if ( useNamed ) { return new NamedEnumValueConverter( javaTypeDescriptor ); } else { return new OrdinalEnumValueConverter( javaTypeDescriptor ); } } if ( parameters.containsKey( TYPE ) ) { final int type = Integer.decode( (String) parameters.get( TYPE ) ); if ( isNumericType( type ) ) { return new OrdinalEnumValueConverter( javaTypeDescriptor ); } else if ( isCharacterType( type ) ) { return new NamedEnumValueConverter( javaTypeDescriptor ); } else { throw new HibernateException( String.format( Locale.ENGLISH, "Passed JDBC type code [%s] not recognized as numeric nor character", type ) ); } } // the fallback return new OrdinalEnumValueConverter( javaTypeDescriptor ); }
Example #22
Source File: SessionFactoryImpl.java From lams with GNU General Public License v2.0 | 5 votes |
private void logIfEmptyCompositesEnabled(Map<String, Object> props ) { final boolean isEmptyCompositesEnabled = ConfigurationHelper.getBoolean( AvailableSettings.CREATE_EMPTY_COMPOSITES_ENABLED, props, false ); if ( isEmptyCompositesEnabled ) { // It would be nice to do this logging in ComponentMetamodel, where // AvailableSettings.CREATE_EMPTY_COMPOSITES_ENABLED is actually used. // Unfortunately that would end up logging a message several times for // each embeddable/composite. Doing it here will log the message only // once. LOG.emptyCompositesEnabled(); } }
Example #23
Source File: DriverManagerConnectionProviderImpl.java From lams with GNU General Public License v2.0 | 5 votes |
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 = ConnectionProviderInitiator.extractIsolation( configurationValues ); if ( isolation != null ) { log.jdbcIsolationLevel( ConnectionProviderInitiator.toIsolationNiceName( isolation ) ); } connectionCreatorBuilder.setIsolation( isolation ); return connectionCreatorBuilder.build(); }
Example #24
Source File: SequenceHiLoGenerator.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void configure(Type type, Properties params, ServiceRegistry serviceRegistry) throws MappingException { super.configure( type, params, serviceRegistry ); maxLo = ConfigurationHelper.getInt( MAX_LO, params, 9 ); if ( maxLo >= 1 ) { hiloOptimizer = new LegacyHiLoAlgorithmOptimizer( getIdentifierType().getReturnedClass(), maxLo ); } }
Example #25
Source File: AbstractServiceRegistryImpl.java From lams with GNU General Public License v2.0 | 5 votes |
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 ); }
Example #26
Source File: ComponentMetamodel.java From lams with GNU General Public License v2.0 | 5 votes |
private ComponentMetamodel(Component component, ComponentTuplizerFactory componentTuplizerFactory){ this.role = component.getRoleName(); this.isKey = component.isKey(); propertySpan = component.getPropertySpan(); properties = new StandardProperty[propertySpan]; Iterator itr = component.getPropertyIterator(); int i = 0; while ( itr.hasNext() ) { Property property = ( Property ) itr.next(); properties[i] = PropertyFactory.buildStandardProperty( property, false ); propertyIndexes.put( property.getName(), i ); i++; } entityMode = component.hasPojoRepresentation() ? EntityMode.POJO : EntityMode.MAP; // todo : move this to SF per HHH-3517; also see HHH-1907 and ComponentMetamodel final String tuplizerClassName = component.getTuplizerImplClassName( entityMode ); this.componentTuplizer = tuplizerClassName == null ? componentTuplizerFactory.constructDefaultTuplizer( entityMode, component ) : componentTuplizerFactory.constructTuplizer( tuplizerClassName, component ); final ConfigurationService cs = component.getMetadata().getMetadataBuildingOptions().getServiceRegistry() .getService(ConfigurationService.class); this.createEmptyCompositesEnabled = ConfigurationHelper.getBoolean( Environment.CREATE_EMPTY_COMPOSITES_ENABLED, cs.getSettings(), false ); }
Example #27
Source File: SequenceStyleGenerator.java From lams with GNU General Public License v2.0 | 5 votes |
@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, serviceRegistry ); 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 ); }
Example #28
Source File: TableGenerator.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void configure(Type type, Properties params, ServiceRegistry serviceRegistry) throws MappingException { storeLastUsedValue = serviceRegistry.getService( ConfigurationService.class ) .getSetting( AvailableSettings.TABLE_GENERATOR_STORE_LAST_USED, StandardConverters.BOOLEAN, true ); identifierType = type; final JdbcEnvironment jdbcEnvironment = serviceRegistry.getService( JdbcEnvironment.class ); qualifiedTableName = determineGeneratorTableName( params, jdbcEnvironment, serviceRegistry ); segmentColumnName = determineSegmentColumnName( params, jdbcEnvironment ); valueColumnName = determineValueColumnName( params, jdbcEnvironment ); segmentValue = determineSegmentValue( params ); segmentValueLength = determineSegmentColumnSize( params ); initialValue = determineInitialValue( params ); incrementSize = determineIncrementSize( params ); final String optimizationStrategy = ConfigurationHelper.getString( OPT_PARAM, params, OptimizerFactory.determineImplicitOptimizerName( incrementSize, params ) ); int optimizerInitialValue = ConfigurationHelper.getInt( INITIAL_PARAM, params, -1 ); optimizer = OptimizerFactory.buildOptimizer( optimizationStrategy, identifierType.getReturnedClass(), incrementSize, optimizerInitialValue ); }
Example #29
Source File: TableGenerator.java From lams with GNU General Public License v2.0 | 5 votes |
/** * 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 jdbcEnvironment The JDBC environment * @return The table name to use. */ @SuppressWarnings({"UnusedParameters", "WeakerAccess"}) protected QualifiedName determineGeneratorTableName(Properties params, JdbcEnvironment jdbcEnvironment, ServiceRegistry serviceRegistry) { String fallbackTableName = DEF_TABLE; final Boolean preferGeneratorNameAsDefaultName = serviceRegistry.getService( ConfigurationService.class ) .getSetting( AvailableSettings.PREFER_GENERATOR_NAME_AS_DEFAULT_SEQUENCE_NAME, StandardConverters.BOOLEAN, true ); if ( preferGeneratorNameAsDefaultName ) { final String generatorName = params.getProperty( IdentifierGenerator.GENERATOR_NAME ); if ( StringHelper.isNotEmpty( generatorName ) ) { fallbackTableName = generatorName; } } String tableName = ConfigurationHelper.getString( TABLE_PARAM, params, fallbackTableName ); if ( tableName.contains( "." ) ) { return QualifiedNameParser.INSTANCE.parse( tableName ); } else { // todo : need to incorporate implicit catalog and schema names final Identifier catalog = jdbcEnvironment.getIdentifierHelper().toIdentifier( ConfigurationHelper.getString( CATALOG, params ) ); final Identifier schema = jdbcEnvironment.getIdentifierHelper().toIdentifier( ConfigurationHelper.getString( SCHEMA, params ) ); return new QualifiedNameParser.NameParts( catalog, schema, jdbcEnvironment.getIdentifierHelper().toIdentifier( tableName ) ); } }
Example #30
Source File: TableGenerator.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Used in the cases where {@link #determineSegmentValue} is unable to * determine the value to use. * * @param params The params supplied in the generator config (plus some standard useful extras). * @return The default segment value to use. */ @SuppressWarnings("WeakerAccess") protected String determineDefaultSegmentValue(Properties params) { final boolean preferSegmentPerEntity = ConfigurationHelper.getBoolean( CONFIG_PREFER_SEGMENT_PER_ENTITY, params, false ); final String defaultToUse = preferSegmentPerEntity ? params.getProperty( TABLE ) : DEF_SEGMENT_VALUE; LOG.usingDefaultIdGeneratorSegmentValue( qualifiedTableName.render(), segmentColumnName, defaultToUse ); return defaultToUse; }