Java Code Examples for org.hibernate.boot.registry.StandardServiceRegistryBuilder#applySettings()
The following examples show how to use
org.hibernate.boot.registry.StandardServiceRegistryBuilder#applySettings() .
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: SchemaExport.java From lams with GNU General Public License v2.0 | 6 votes |
private static StandardServiceRegistry buildStandardServiceRegistry(CommandLineArgs commandLineArgs) throws Exception { final BootstrapServiceRegistry bsr = new BootstrapServiceRegistryBuilder().build(); final StandardServiceRegistryBuilder ssrBuilder = new StandardServiceRegistryBuilder( bsr ); if ( commandLineArgs.cfgXmlFile != null ) { ssrBuilder.configure( commandLineArgs.cfgXmlFile ); } Properties properties = new Properties(); if ( commandLineArgs.propertiesFile != null ) { properties.load( new FileInputStream( commandLineArgs.propertiesFile ) ); } ssrBuilder.applySettings( properties ); return ssrBuilder.build(); }
Example 2
Source File: SchemaUpdateTask.java From lams with GNU General Public License v2.0 | 6 votes |
private void configure(StandardServiceRegistryBuilder registryBuilder) throws IOException { if ( configurationFile != null ) { registryBuilder.configure( configurationFile ); } Properties properties = new Properties(); if ( propertiesFile == null ) { properties.putAll( getProject().getProperties() ); } else { try (FileInputStream fip = new FileInputStream( propertiesFile )){ properties.load( fip ); } } registryBuilder.applySettings( properties ); }
Example 3
Source File: SchemaUpdate.java From lams with GNU General Public License v2.0 | 6 votes |
private static StandardServiceRegistry buildStandardServiceRegistry(CommandLineArgs parsedArgs) throws Exception { final BootstrapServiceRegistry bsr = new BootstrapServiceRegistryBuilder().build(); final StandardServiceRegistryBuilder ssrBuilder = new StandardServiceRegistryBuilder( bsr ); if ( parsedArgs.cfgXmlFile != null ) { ssrBuilder.configure( parsedArgs.cfgXmlFile ); } if ( parsedArgs.propertiesFile != null ) { Properties props = new Properties(); props.load( new FileInputStream( parsedArgs.propertiesFile ) ); ssrBuilder.applySettings( props ); } return ssrBuilder.build(); }
Example 4
Source File: SchemaValidator.java From lams with GNU General Public License v2.0 | 6 votes |
private static StandardServiceRegistry buildStandardServiceRegistry(CommandLineArgs parsedArgs) throws Exception { final BootstrapServiceRegistry bsr = new BootstrapServiceRegistryBuilder().build(); final StandardServiceRegistryBuilder ssrBuilder = new StandardServiceRegistryBuilder( bsr ); if ( parsedArgs.cfgXmlFile != null ) { ssrBuilder.configure( parsedArgs.cfgXmlFile ); } if ( parsedArgs.propertiesFile != null ) { Properties properties = new Properties(); properties.load( new FileInputStream( parsedArgs.propertiesFile ) ); ssrBuilder.applySettings( properties ); } return ssrBuilder.build(); }
Example 5
Source File: HibernateUtil.java From primefaces-blueprints with The Unlicense | 5 votes |
private static SessionFactory buildSessionFactory() throws HibernateException { Configuration configuration = new Configuration().configure(); // configures settings from hibernate.cfg.xml StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder(); // If you miss the below line then it will complain about a missing dialect setting serviceRegistryBuilder.applySettings(configuration.getProperties()); ServiceRegistry serviceRegistry = serviceRegistryBuilder.build(); return configuration.buildSessionFactory(serviceRegistry); }
Example 6
Source File: JpaConfiguration.java From micronaut-sql with Apache License 2.0 | 5 votes |
/** * Builds the standard service registry. * * @param additionalSettings Additional settings for the service registry * @return The standard service registry */ @SuppressWarnings("WeakerAccess") public StandardServiceRegistry buildStandardServiceRegistry(@Nullable Map<String, Object> additionalSettings) { StandardServiceRegistryBuilder standardServiceRegistryBuilder = createStandServiceRegistryBuilder(bootstrapServiceRegistry); Map<String, Object> jpaProperties = getProperties(); if (CollectionUtils.isNotEmpty(jpaProperties)) { standardServiceRegistryBuilder.applySettings(jpaProperties); } if (additionalSettings != null) { standardServiceRegistryBuilder.applySettings(additionalSettings); } return standardServiceRegistryBuilder.build(); }
Example 7
Source File: HibernateUtil.java From primefaces-blueprints with The Unlicense | 5 votes |
private static SessionFactory buildSessionFactory() throws HibernateException { Configuration configuration = new Configuration().configure(); // configures settings from hibernate.cfg.xml StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder(); // If you miss the below line then it will complain about a missing dialect setting serviceRegistryBuilder.applySettings(configuration.getProperties()); ServiceRegistry serviceRegistry = serviceRegistryBuilder.build(); return configuration.buildSessionFactory(serviceRegistry); }
Example 8
Source File: HibernateUtil.java From primefaces-blueprints with The Unlicense | 5 votes |
private static SessionFactory buildSessionFactory() throws HibernateException { Configuration configuration = new Configuration().configure(); // configures settings from hibernate.cfg.xml StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder(); // If you miss the below line then it will complain about a missing dialect setting serviceRegistryBuilder.applySettings(configuration.getProperties()); ServiceRegistry serviceRegistry = serviceRegistryBuilder.build(); return configuration.buildSessionFactory(serviceRegistry); }
Example 9
Source File: HibernateUtil.java From primefaces-blueprints with The Unlicense | 5 votes |
private static SessionFactory buildSessionFactory() throws HibernateException { Configuration configuration = new Configuration().configure(); // configures settings from hibernate.cfg.xml StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder(); // If you miss the below line then it will complain about a missing dialect setting serviceRegistryBuilder.applySettings(configuration.getProperties()); ServiceRegistry serviceRegistry = serviceRegistryBuilder.build(); return configuration.buildSessionFactory(serviceRegistry); }
Example 10
Source File: HibernateUtil.java From primefaces-blueprints with The Unlicense | 5 votes |
private static SessionFactory buildSessionFactory() throws HibernateException { Configuration configuration = new Configuration().configure(); // configures settings from hibernate.cfg.xml StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder(); // If you miss the below line then it will complain about a missing dialect setting serviceRegistryBuilder.applySettings(configuration.getProperties()); ServiceRegistry serviceRegistry = serviceRegistryBuilder.build(); return configuration.buildSessionFactory(serviceRegistry); }
Example 11
Source File: HibernateL2CacheConfigurationSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @param igniteInstanceName Name of the grid providing caches. * @return Session factory. */ private SessionFactory startHibernate(String igniteInstanceName) { Configuration cfg = hibernateConfiguration(igniteInstanceName); StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder(); builder.applySetting("hibernate.connection.url", CONNECTION_URL); builder.applySetting("hibernate.show_sql", false); builder.applySettings(cfg.getProperties()); return cfg.buildSessionFactory(builder.build()); }
Example 12
Source File: HibernateL2CacheConfigurationSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @param igniteInstanceName Name of the grid providing caches. * @return Session factory. */ private SessionFactory startHibernate(String igniteInstanceName) { Configuration cfg = hibernateConfiguration(igniteInstanceName); StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder(); builder.applySetting("hibernate.connection.url", CONNECTION_URL); builder.applySetting("hibernate.show_sql", false); builder.applySettings(cfg.getProperties()); return cfg.buildSessionFactory(builder.build()); }
Example 13
Source File: HibernateUtil.java From TomboloDigitalConnector with MIT License | 5 votes |
private static SessionFactory buildSessionFactoryForPython() { SessionFactory factory; StandardServiceRegistry registry; try { StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder(); Map<String, String> settings = new HashMap<>(); settings.put(Environment.DRIVER, "org.postgresql.Driver"); settings.put(Environment.URL, "jdbc:postgresql://localhost:5432/tombolo"); settings.put(Environment.USER, "tombolo"); settings.put(Environment.PASS, "tombolo"); settings.put(Environment.DIALECT, "org.hibernate.spatial.dialect.postgis.PostgisDialect"); registryBuilder.applySettings(settings); registry = registryBuilder.build(); MetadataSources sources = new MetadataSources(registry) .addAnnotatedClass(uk.org.tombolo.core.Provider.class) .addAnnotatedClass(uk.org.tombolo.core.Attribute.class) .addAnnotatedClass(uk.org.tombolo.core.Subject.class) .addAnnotatedClass(uk.org.tombolo.core.SubjectType.class) .addAnnotatedClass(uk.org.tombolo.core.FixedValue.class) .addAnnotatedClass(uk.org.tombolo.core.TimedValue.class); Metadata metadata = sources.getMetadataBuilder().build(); factory = metadata.getSessionFactoryBuilder().build(); } catch (Exception ex) { throw new ServiceConfigurationError("Failed to create SessionFactory", ex); } return factory; }
Example 14
Source File: SchemaValidatorTask.java From lams with GNU General Public License v2.0 | 5 votes |
private void configure(StandardServiceRegistryBuilder registryBuilder) throws IOException { if ( configurationFile != null ) { registryBuilder.configure( configurationFile ); } Properties properties = new Properties(); if ( propertiesFile == null ) { properties.putAll( getProject().getProperties() ); } else { properties.load( new FileInputStream( propertiesFile ) ); } registryBuilder.applySettings( properties ); }
Example 15
Source File: DBService.java From stepic_java_webserver with MIT License | 4 votes |
private static SessionFactory createSessionFactory(Configuration configuration) { StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder(); builder.applySettings(configuration.getProperties()); ServiceRegistry serviceRegistry = builder.build(); return configuration.buildSessionFactory(serviceRegistry); }
Example 16
Source File: DBServiceImpl.java From tp_java_2015_02 with MIT License | 4 votes |
private static SessionFactory createSessionFactory(Configuration configuration) { StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder(); builder.applySettings(configuration.getProperties()); ServiceRegistry serviceRegistry = builder.build(); return configuration.buildSessionFactory(serviceRegistry); }
Example 17
Source File: EntityManagerFactoryBuilderImpl.java From lams with GNU General Public License v2.0 | 4 votes |
private EntityManagerFactoryBuilderImpl( PersistenceUnitDescriptor persistenceUnit, Map integrationSettings, ClassLoader providedClassLoader, ClassLoaderService providedClassLoaderService) { LogHelper.logPersistenceUnitInformation( persistenceUnit ); this.persistenceUnit = persistenceUnit; if ( integrationSettings == null ) { integrationSettings = Collections.emptyMap(); } // Build the boot-strap service registry, which mainly handles class loader interactions final BootstrapServiceRegistry bsr = buildBootstrapServiceRegistry( integrationSettings, providedClassLoader, providedClassLoaderService); // merge configuration sources and build the "standard" service registry final StandardServiceRegistryBuilder ssrBuilder = new StandardServiceRegistryBuilder( bsr ); final MergedSettings mergedSettings = mergeSettings( persistenceUnit, integrationSettings, ssrBuilder ); this.configurationValues = mergedSettings.getConfigurationValues(); // Build the "standard" service registry ssrBuilder.applySettings( configurationValues ); configure( ssrBuilder ); this.standardServiceRegistry = ssrBuilder.build(); configure( standardServiceRegistry, mergedSettings ); final MetadataSources metadataSources = new MetadataSources( bsr ); List<AttributeConverterDefinition> attributeConverterDefinitions = populate( metadataSources, mergedSettings, standardServiceRegistry ); this.metamodelBuilder = (MetadataBuilderImplementor) metadataSources.getMetadataBuilder( standardServiceRegistry ); populate( metamodelBuilder, mergedSettings, standardServiceRegistry, attributeConverterDefinitions ); // todo : would be nice to have MetadataBuilder still do the handling of CfgXmlAccessService here // another option is to immediately handle them here (probably in mergeSettings?) as we encounter them... final CfgXmlAccessService cfgXmlAccessService = standardServiceRegistry.getService( CfgXmlAccessService.class ); if ( cfgXmlAccessService.getAggregatedConfig() != null ) { if ( cfgXmlAccessService.getAggregatedConfig().getMappingReferences() != null ) { for ( MappingReference mappingReference : cfgXmlAccessService.getAggregatedConfig().getMappingReferences() ) { mappingReference.apply( metadataSources ); } } } this.managedResources = MetadataBuildingProcess.prepare( metadataSources, metamodelBuilder.getBootstrapContext() ); applyMetadataBuilderContributor(); withValidatorFactory( configurationValues.get( org.hibernate.cfg.AvailableSettings.JPA_VALIDATION_FACTORY ) ); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // push back class transformation to the environment; for the time being this only has any effect in EE // container situations, calling back into PersistenceUnitInfo#addClassTransformer final boolean dirtyTrackingEnabled = readBooleanConfigurationValue( AvailableSettings.ENHANCER_ENABLE_DIRTY_TRACKING ); final boolean lazyInitializationEnabled = readBooleanConfigurationValue( AvailableSettings.ENHANCER_ENABLE_LAZY_INITIALIZATION ); final boolean associationManagementEnabled = readBooleanConfigurationValue( AvailableSettings.ENHANCER_ENABLE_ASSOCIATION_MANAGEMENT ); if ( dirtyTrackingEnabled || lazyInitializationEnabled || associationManagementEnabled ) { EnhancementContext enhancementContext = getEnhancementContext( dirtyTrackingEnabled, lazyInitializationEnabled, associationManagementEnabled ); persistenceUnit.pushClassTransformer( enhancementContext ); } // for the time being we want to revoke access to the temp ClassLoader if one was passed metamodelBuilder.applyTempClassLoader( null ); }