Search in sources :

Example 6 with StrategySelector

use of org.hibernate.boot.registry.selector.spi.StrategySelector in project hibernate-orm by hibernate.

the class EntityManagerFactoryBuilderImpl method configure.

private void configure(StandardServiceRegistry ssr, MergedSettings mergedSettings) {
    final StrategySelector strategySelector = ssr.getService(StrategySelector.class);
    // apply id generators
    final Object idGeneratorStrategyProviderSetting = configurationValues.remove(AvailableSettings.IDENTIFIER_GENERATOR_STRATEGY_PROVIDER);
    if (idGeneratorStrategyProviderSetting != null) {
        final IdentifierGeneratorStrategyProvider idGeneratorStrategyProvider = strategySelector.resolveStrategy(IdentifierGeneratorStrategyProvider.class, idGeneratorStrategyProviderSetting);
        final MutableIdentifierGeneratorFactory identifierGeneratorFactory = ssr.getService(MutableIdentifierGeneratorFactory.class);
        if (identifierGeneratorFactory == null) {
            throw persistenceException("Application requested custom identifier generator strategies, " + "but the MutableIdentifierGeneratorFactory could not be found");
        }
        for (Map.Entry<String, Class<?>> entry : idGeneratorStrategyProvider.getStrategies().entrySet()) {
            identifierGeneratorFactory.register(entry.getKey(), entry.getValue());
        }
    }
}
Also used : MutableIdentifierGeneratorFactory(org.hibernate.id.factory.spi.MutableIdentifierGeneratorFactory) IdentifierGeneratorStrategyProvider(org.hibernate.jpa.spi.IdentifierGeneratorStrategyProvider) UnloadedClass(org.hibernate.bytecode.enhance.spi.UnloadedClass) StrategySelector(org.hibernate.boot.registry.selector.spi.StrategySelector) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap)

Example 7 with StrategySelector

use of org.hibernate.boot.registry.selector.spi.StrategySelector in project hibernate-orm by hibernate.

the class SchemaExport method buildMetadata.

private static MetadataImplementor buildMetadata(CommandLineArgs parsedArgs, StandardServiceRegistry serviceRegistry) throws Exception {
    final MetadataSources metadataSources = new MetadataSources(serviceRegistry);
    for (String filename : parsedArgs.hbmXmlFiles) {
        metadataSources.addFile(filename);
    }
    for (String filename : parsedArgs.jarFiles) {
        metadataSources.addJar(new File(filename));
    }
    final MetadataBuilder metadataBuilder = metadataSources.getMetadataBuilder();
    final StrategySelector strategySelector = serviceRegistry.getService(StrategySelector.class);
    if (parsedArgs.implicitNamingStrategyImplName != null) {
        metadataBuilder.applyImplicitNamingStrategy(strategySelector.resolveStrategy(ImplicitNamingStrategy.class, parsedArgs.implicitNamingStrategyImplName));
    }
    if (parsedArgs.physicalNamingStrategyImplName != null) {
        metadataBuilder.applyPhysicalNamingStrategy(strategySelector.resolveStrategy(PhysicalNamingStrategy.class, parsedArgs.physicalNamingStrategyImplName));
    }
    return (MetadataImplementor) metadataBuilder.build();
}
Also used : ImplicitNamingStrategy(org.hibernate.boot.model.naming.ImplicitNamingStrategy) MetadataBuilder(org.hibernate.boot.MetadataBuilder) MetadataSources(org.hibernate.boot.MetadataSources) MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) File(java.io.File) StrategySelector(org.hibernate.boot.registry.selector.spi.StrategySelector) PhysicalNamingStrategy(org.hibernate.boot.model.naming.PhysicalNamingStrategy)

Example 8 with StrategySelector

use of org.hibernate.boot.registry.selector.spi.StrategySelector in project hibernate-orm by hibernate.

the class SchemaValidator method buildMetadata.

private static MetadataImplementor buildMetadata(CommandLineArgs parsedArgs, StandardServiceRegistry serviceRegistry) throws Exception {
    final MetadataSources metadataSources = new MetadataSources(serviceRegistry);
    for (String filename : parsedArgs.hbmXmlFiles) {
        metadataSources.addFile(filename);
    }
    for (String filename : parsedArgs.jarFiles) {
        metadataSources.addJar(new File(filename));
    }
    final MetadataBuilder metadataBuilder = metadataSources.getMetadataBuilder();
    final StrategySelector strategySelector = serviceRegistry.getService(StrategySelector.class);
    if (parsedArgs.implicitNamingStrategy != null) {
        metadataBuilder.applyImplicitNamingStrategy(strategySelector.resolveStrategy(ImplicitNamingStrategy.class, parsedArgs.implicitNamingStrategy));
    }
    if (parsedArgs.physicalNamingStrategy != null) {
        metadataBuilder.applyPhysicalNamingStrategy(strategySelector.resolveStrategy(PhysicalNamingStrategy.class, parsedArgs.physicalNamingStrategy));
    }
    return (MetadataImplementor) metadataBuilder.build();
}
Also used : ImplicitNamingStrategy(org.hibernate.boot.model.naming.ImplicitNamingStrategy) MetadataBuilder(org.hibernate.boot.MetadataBuilder) MetadataSources(org.hibernate.boot.MetadataSources) MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) File(java.io.File) StrategySelector(org.hibernate.boot.registry.selector.spi.StrategySelector) PhysicalNamingStrategy(org.hibernate.boot.model.naming.PhysicalNamingStrategy)

Example 9 with StrategySelector

use of org.hibernate.boot.registry.selector.spi.StrategySelector in project hibernate-orm by hibernate.

the class OracleSDOSupport method mkSdoGeometryTypeDescriptor.

private SDOGeometryTypeDescriptor mkSdoGeometryTypeDescriptor(ServiceRegistry serviceRegistry) {
    final ConfigurationService cfgService = serviceRegistry.getService(ConfigurationService.class);
    final StrategySelector strategySelector = serviceRegistry.getService(StrategySelector.class);
    final ConnectionFinder connectionFinder = strategySelector.resolveStrategy(ConnectionFinder.class, cfgService.getSetting(HibernateSpatialConfigurationSettings.CONNECTION_FINDER, String.class, "org.geolatte.geom.codec.db.oracle.DefaultConnectionFinder"));
    log.connectionFinder(connectionFinder.getClass().getCanonicalName());
    return new SDOGeometryTypeDescriptor(new OracleJDBCTypeFactory(connectionFinder));
}
Also used : OracleJDBCTypeFactory(org.geolatte.geom.codec.db.oracle.OracleJDBCTypeFactory) ConfigurationService(org.hibernate.engine.config.spi.ConfigurationService) ConnectionFinder(org.geolatte.geom.codec.db.oracle.ConnectionFinder) StrategySelector(org.hibernate.boot.registry.selector.spi.StrategySelector)

Aggregations

StrategySelector (org.hibernate.boot.registry.selector.spi.StrategySelector)9 File (java.io.File)3 MetadataBuilder (org.hibernate.boot.MetadataBuilder)3 MetadataSources (org.hibernate.boot.MetadataSources)3 ImplicitNamingStrategy (org.hibernate.boot.model.naming.ImplicitNamingStrategy)3 PhysicalNamingStrategy (org.hibernate.boot.model.naming.PhysicalNamingStrategy)3 MetadataImplementor (org.hibernate.boot.spi.MetadataImplementor)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ConfigurationService (org.hibernate.engine.config.spi.ConfigurationService)2 BeanInfo (java.beans.BeanInfo)1 PropertyDescriptor (java.beans.PropertyDescriptor)1 Method (java.lang.reflect.Method)1 ConnectionFinder (org.geolatte.geom.codec.db.oracle.ConnectionFinder)1 OracleJDBCTypeFactory (org.geolatte.geom.codec.db.oracle.OracleJDBCTypeFactory)1 HibernateException (org.hibernate.HibernateException)1 MultiTenancyStrategy (org.hibernate.MultiTenancyStrategy)1 SessionFactoryObserver (org.hibernate.SessionFactoryObserver)1 SessionFactoryBuilderImplementor (org.hibernate.boot.spi.SessionFactoryBuilderImplementor)1