本文整理汇总了Java中org.hibernate.engine.config.spi.ConfigurationService类的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationService类的具体用法?Java ConfigurationService怎么用?Java ConfigurationService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConfigurationService类属于org.hibernate.engine.config.spi包,在下文中一共展示了ConfigurationService类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SchemaExport
import org.hibernate.engine.config.spi.ConfigurationService; //导入依赖的package包/类
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 );
}
示例2: createEntityCopyObserver
import org.hibernate.engine.config.spi.ConfigurationService; //导入依赖的package包/类
private EntityCopyObserver createEntityCopyObserver(SessionFactoryImplementor sessionFactory) {
final ServiceRegistry serviceRegistry = sessionFactory.getServiceRegistry();
if ( entityCopyObserverStrategy == null ) {
final ConfigurationService configurationService
= serviceRegistry.getService( ConfigurationService.class );
entityCopyObserverStrategy = configurationService.getSetting(
"hibernate.event.merge.entity_copy_observer",
new ConfigurationService.Converter<String>() {
@Override
public String convert(Object value) {
return value.toString();
}
},
EntityCopyNotAllowedObserver.SHORT_NAME
);
LOG.debugf( "EntityCopyObserver strategy: %s", entityCopyObserverStrategy );
}
final StrategySelector strategySelector = serviceRegistry.getService( StrategySelector.class );
return strategySelector.resolveStrategy( EntityCopyObserver.class, entityCopyObserverStrategy );
}
示例3: testCreationOfSessionFactory
import org.hibernate.engine.config.spi.ConfigurationService; //导入依赖的package包/类
@Test
public void testCreationOfSessionFactory() {
Properties props = getProperties();
Config conf = ConfigFactory.parseProperties(props);
hs = new HibernateService(conf);
SessionFactory sf = hs.getSessionFactory();
assertNotNull(sf);
assertFalse(sf.isClosed());
// traverse through the session factory to get at configuration values
SessionFactoryOptions sfo = sf.getSessionFactoryOptions();
StandardServiceRegistry ssr = sfo.getServiceRegistry();
ConfigurationService cs = ssr.getService(ConfigurationService.class);
assertEquals(props.getProperty("hibernate.connection.driver_class"), cs.getSetting("hibernate.connection.driver_class", StandardConverters.STRING));
assertEquals(props.getProperty("hibernate.connection.url"), cs.getSetting("hibernate.connection.url", StandardConverters.STRING));
assertEquals(props.getProperty("hibernate.dialect"), cs.getSetting("hibernate.dialect", StandardConverters.STRING));
assertEquals(props.getProperty("hibernate.hbm2ddl.auto"), cs.getSetting("hibernate.hbm2ddl.auto", StandardConverters.STRING));
// check mapping
ClassMetadata cm = sf.getClassMetadata(TestObject.class);
String[] names = cm.getPropertyNames();
assertEquals(1, names.length);
assertEquals("name", names[0]);
assertEquals("string", cm.getPropertyType("name").getName());
}
示例4: getAlterTableToAddUniqueKeyCommand
import org.hibernate.engine.config.spi.ConfigurationService; //导入依赖的package包/类
@Override
public String getAlterTableToAddUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata)
{
ConfigurationService config = metadata.getDatabase().getBuildingOptions().getServiceRegistry()
.getService(ConfigurationService.class);
if (config != null)
{
String value = config.getSetting("hibernate.hbm2ddl.auto", StandardConverters.STRING);
if (!value.equalsIgnoreCase("update"))
{
// We should only check whether it is already present in an
// update scenario, in all other scenarios, just return the
// actual create statement.
return org.hibernate.mapping.Index.buildSqlCreateIndexString(dialect, uniqueKey.getName(),
uniqueKey.getTable(), uniqueKey.columnIterator(), uniqueKey.getColumnOrderMap(), true,
metadata);
}
}
// First check that this unique key is not already present, as this is a
// lot faster than trying to create it and then fail.
initIndices();
UniqueIndex idx = indices.getIndex(uniqueKey);
if (idx != null)
{
return null;
}
return org.hibernate.mapping.Index.buildSqlCreateIndexString(dialect, uniqueKey.getName(), uniqueKey.getTable(),
uniqueKey.columnIterator(), uniqueKey.getColumnOrderMap(), true, metadata);
}
示例5: resolve
import org.hibernate.engine.config.spi.ConfigurationService; //导入依赖的package包/类
@SuppressWarnings( {"unchecked"} )
void resolve() {
for ( EntityBinding entityBinding : metadata.getEntityBindings() ) {
if ( entityBinding.isRoot() ) {
Properties properties = new Properties( );
properties.putAll(
metadata.getServiceRegistry()
.getService( ConfigurationService.class )
.getSettings()
);
//TODO: where should these be added???
if ( ! properties.contains( AvailableSettings.PREFER_POOLED_VALUES_LO ) ) {
properties.put( AvailableSettings.PREFER_POOLED_VALUES_LO, "false" );
}
if ( ! properties.contains( PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER ) ) {
properties.put(
PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER,
new ObjectNameNormalizerImpl( metadata )
);
}
entityBinding.getHierarchyDetails().getEntityIdentifier().createIdentifierGenerator(
metadata.getIdentifierGeneratorFactory(),
properties
);
}
}
}
示例6: initiateService
import org.hibernate.engine.config.spi.ConfigurationService; //导入依赖的package包/类
@Override
public StatisticsImplementor initiateService(
SessionFactoryImplementor sessionFactory,
MetadataImplementor metadata,
ServiceRegistryImplementor registry) {
ConfigurationService configurationService = registry.getService( ConfigurationService.class );
final Object configValue = configurationService.getSetting( STATS_BUILDER, null );
return initiateServiceInternal( sessionFactory, configValue, registry );
}
示例7: determineCurrentTenantIdentifierResolver
import org.hibernate.engine.config.spi.ConfigurationService; //导入依赖的package包/类
@SuppressWarnings({ "unchecked" })
private CurrentTenantIdentifierResolver determineCurrentTenantIdentifierResolver(
CurrentTenantIdentifierResolver explicitResolver) {
if ( explicitResolver != null ) {
return explicitResolver;
}
return serviceRegistry.getService( ConfigurationService.class )
.getSetting(
AvailableSettings.MULTI_TENANT_IDENTIFIER_RESOLVER,
CurrentTenantIdentifierResolver.class,
null
);
}
示例8: injectServices
import org.hibernate.engine.config.spi.ConfigurationService; //导入依赖的package包/类
@Override
public void injectServices(ServiceRegistryImplementor serviceRegistry) {
Map settings = serviceRegistry.getService(ConfigurationService.class).getSettings();
DataSource dataSource = (DataSource) settings.get(Environment.DATASOURCE);
datasourceConnectionProvider.setDataSource(dataSource);
datasourceConnectionProvider.configure(settings);
logger.debug("connection provider:{}", datasourceConnectionProvider);
}
示例9: prepare
import org.hibernate.engine.config.spi.ConfigurationService; //导入依赖的package包/类
@Override
public void prepare(JdbcServices jdbcServices, JdbcConnectionAccess connectionAccess, MetadataImplementor metadata, SessionFactoryOptions sessionFactoryOptions) {
ConfigurationService configService = sessionFactoryOptions.getServiceRegistry().getService(ConfigurationService.class);
this.fullyQualifiedTableName = Objects.requireNonNull(configService.getSetting(TABLE, String.class, null), "Property " + TABLE + " must be set.");
this.idColumn = configService.getSetting(ID_COLUMN, String.class, "ID");
this.discriminatorColumn = configService.getSetting(DISCRIMINATOR_COLUMN, String.class, "ENTITY_NAME");
this.cleanRows = configService.getSetting(CLEAN_ROWS, StandardConverters.BOOLEAN, false);
}
开发者ID:grimsa,项目名称:hibernate-single-table-bulk-id-strategy,代码行数:9,代码来源:SingleGlobalTemporaryTableBulkIdStrategy.java
示例10: injectServices
import org.hibernate.engine.config.spi.ConfigurationService; //导入依赖的package包/类
@Override
public void injectServices(ServiceRegistryImplementor serviceRegistry) {
final Object dataSourceConfigValue = serviceRegistry.getService( ConfigurationService.class )
.getSettings()
.get( AvailableSettings.DATASOURCE );
if ( dataSourceConfigValue == null || ! String.class.isInstance( dataSourceConfigValue ) ) {
throw new HibernateException( "Improper set up of DataSourceBasedMultiTenantConnectionProviderImpl" );
}
final String jndiName = (String) dataSourceConfigValue;
jndiService = serviceRegistry.getService( JndiService.class );
if ( jndiService == null ) {
throw new HibernateException( "Could not locate JndiService from DataSourceBasedMultiTenantConnectionProviderImpl" );
}
final Object namedObject = jndiService.locate( jndiName );
if ( namedObject == null ) {
throw new HibernateException( "JNDI name [" + jndiName + "] could not be resolved" );
}
if ( DataSource.class.isInstance( namedObject ) ) {
final int loc = jndiName.lastIndexOf( "/" );
this.baseJndiNamespace = jndiName.substring( 0, loc );
this.tenantIdentifierForAny = jndiName.substring( loc + 1 );
dataSourceMap().put( tenantIdentifierForAny, (DataSource) namedObject );
}
else if ( Context.class.isInstance( namedObject ) ) {
this.baseJndiNamespace = jndiName;
this.tenantIdentifierForAny = (String) serviceRegistry.getService( ConfigurationService.class )
.getSettings()
.get( TENANT_IDENTIFIER_TO_USE_FOR_ANY_KEY );
if ( tenantIdentifierForAny == null ) {
throw new HibernateException( "JNDI name named a Context, but tenant identifier to use for ANY was not specified" );
}
}
else {
throw new HibernateException(
"Unknown object type [" + namedObject.getClass().getName() +
"] found in JNDI location [" + jndiName + "]"
);
}
}
示例11: initiateService
import org.hibernate.engine.config.spi.ConfigurationService; //导入依赖的package包/类
@Override
public ConfigurationService initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
return new ConfigurationServiceImpl( configurationValues );
}
示例12: getServiceInitiated
import org.hibernate.engine.config.spi.ConfigurationService; //导入依赖的package包/类
@Override
public Class<ConfigurationService> getServiceInitiated() {
return ConfigurationService.class;
}
示例13: injectServices
import org.hibernate.engine.config.spi.ConfigurationService; //导入依赖的package包/类
@Override
public void injectServices(ServiceRegistryImplementor serviceRegistry) {
Map lSettings = serviceRegistry.getService(ConfigurationService.class).getSettings();
lazyDatasource = (DataSource) lSettings.get(Environment.DATASOURCE);
}
示例14: configure
import org.hibernate.engine.config.spi.ConfigurationService; //导入依赖的package包/类
@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));
}
开发者ID:vladmihalcea,项目名称:high-performance-java-persistence,代码行数:37,代码来源:StringSequenceIdentifier.java