本文整理汇总了Java中org.hibernate.internal.util.config.ConfigurationHelper类的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationHelper类的具体用法?Java ConfigurationHelper怎么用?Java ConfigurationHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConfigurationHelper类属于org.hibernate.internal.util.config包,在下文中一共展示了ConfigurationHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
import org.hibernate.internal.util.config.ConfigurationHelper; //导入依赖的package包/类
@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 );
}
示例2: buildSessionFactory
import org.hibernate.internal.util.config.ConfigurationHelper; //导入依赖的package包/类
/**
* 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
);
}
示例3: applyRelationalConstraints
import org.hibernate.internal.util.config.ConfigurationHelper; //导入依赖的package包/类
@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()
);
}
示例4: SchemaExport
import org.hibernate.internal.util.config.ConfigurationHelper; //导入依赖的package包/类
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 );
}
示例5: initiateService
import org.hibernate.internal.util.config.ConfigurationHelper; //导入依赖的package包/类
@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 );
}
}
示例6: determineSequenceName
import org.hibernate.internal.util.config.ConfigurationHelper; //导入依赖的package包/类
/**
* 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;
}
示例7: determineGeneratorTableName
import org.hibernate.internal.util.config.ConfigurationHelper; //导入依赖的package包/类
/**
* 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;
}
示例8: build
import org.hibernate.internal.util.config.ConfigurationHelper; //导入依赖的package包/类
/**
* 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
);
}
示例9: readSessionFactory
import org.hibernate.internal.util.config.ConfigurationHelper; //导入依赖的package包/类
@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;
}
示例10: createQueryCacheFactory
import org.hibernate.internal.util.config.ConfigurationHelper; //导入依赖的package包/类
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 );
}
}
示例11: createQueryTranslatorFactory
import org.hibernate.internal.util.config.ConfigurationHelper; //导入依赖的package包/类
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 );
}
}
示例12: DatabaseMetadata
import org.hibernate.internal.util.config.ConfigurationHelper; //导入依赖的package包/类
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" };
}
}
示例13: JmxServiceImpl
import org.hibernate.internal.util.config.ConfigurationHelper; //导入依赖的package包/类
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 )
);
}
示例14: configure
import org.hibernate.internal.util.config.ConfigurationHelper; //导入依赖的package包/类
public void configure(Map configValues) {
cacheTransactionManager = ConfigurationHelper.getBoolean(
AvailableSettings.JTA_CACHE_TM,
configValues,
canCacheTransactionManagerByDefault()
);
cacheUserTransaction = ConfigurationHelper.getBoolean(
AvailableSettings.JTA_CACHE_UT,
configValues,
canCacheUserTransactionByDefault()
);
}
示例15: QueryPlanCache
import org.hibernate.internal.util.config.ConfigurationHelper; //导入依赖的package包/类
/**
* 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 );
}