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 ); }
public static StandardServiceRegistryImpl buildServiceRegistry(Map serviceRegistryConfig) { return (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder() .applySettings( serviceRegistryConfig ) .build(); }
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 ); }
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(); }
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(); }
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(); }
private static StandardServiceRegistryImpl createServiceRegistry(Properties properties) { ConfigurationHelper.resolvePlaceHolders( properties ); return (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().applySettings( properties ).build(); }
/** * 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. * * @return The build {@link SessionFactory} * * @throws HibernateException usually indicates an invalid configuration or invalid mapping information */ public SessionFactory buildSessionFactory() throws HibernateException { log.debug( "Building session factory using internal StandardServiceRegistryBuilder" ); standardServiceRegistryBuilder.applySettings( properties ); return buildSessionFactory( standardServiceRegistryBuilder.build() ); }
StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder(); if ( settings != null ) { ssrb.applySettings( settings );
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(); }
@Before public void setUp() { String poolName = "pool-one"; properties = new Properties(); properties.put( AvailableSettings.PROXOOL_POOL_ALIAS, poolName ); properties.put( AvailableSettings.PROXOOL_PROPERTIES, poolName + ".properties" ); ssr = new StandardServiceRegistryBuilder() .applySettings( properties ) .build(); }
protected final StandardServiceRegistryBuilder constructStandardServiceRegistryBuilder() { final BootstrapServiceRegistryBuilder bsrb = new BootstrapServiceRegistryBuilder(); bsrb.applyClassLoader( getClass().getClassLoader() ); // by default we do not share the BootstrapServiceRegistry nor the StandardServiceRegistry, // so we want the BootstrapServiceRegistry to be automatically closed when the // StandardServiceRegistry is closed. bsrb.enableAutoClose(); configureBootstrapServiceRegistryBuilder( bsrb ); final BootstrapServiceRegistry bsr = bsrb.build(); afterBootstrapServiceRegistryBuilt( bsr ); final Map settings = new HashMap(); addSettings( settings ); final StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder( bsr ); initialize( ssrb ); ssrb.applySettings( settings ); configureStandardServiceRegistryBuilder( ssrb ); return ssrb; }
private SessionFactoryImplementor buildSessionFactory(Class entityClass, boolean strict) { final Map settings = new HashMap(); settings.put( AvailableSettings.USE_SECOND_LEVEL_CACHE, "true" ); settings.put( AvailableSettings.JPA_SHARED_CACHE_MODE, SharedCacheMode.ENABLE_SELECTIVE ); settings.put( AvailableSettings.GENERATE_STATISTICS, "true" ); settings.put( AvailableSettings.HBM2DDL_AUTO, "create-drop" ); if ( strict ) { settings.put( AvailableSettings.JPA_CACHING_COMPLIANCE, "true" ); } final StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder() .applySettings( settings ); return (SessionFactoryImplementor) new MetadataSources( ssrb.build() ) .addAnnotatedClass( Person.class ) .addAnnotatedClass( VersionedPerson.class) .buildMetadata() .buildSessionFactory(); }
private SessionFactory buildSessionFactory() { Map settings = new HashMap(); settings.putAll( Environment.getProperties() ); TestingJtaBootstrap.prepare( settings ); settings.put( AvailableSettings.TRANSACTION_COORDINATOR_STRATEGY, "jta" ); final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().applySettings( settings ).build(); return new MetadataSources( ssr ) .addAnnotatedClass( TestEntity.class ) .buildMetadata() .buildSessionFactory(); }
private SessionFactory buildSessionFactory(HibernateBundle<?> bundle, PooledDataSourceFactory dbConfig, ConnectionProvider connectionProvider, Map<String, String> properties, List<Class<?>> entities) { final Configuration configuration = new Configuration(); configuration.setProperty(AvailableSettings.CURRENT_SESSION_CONTEXT_CLASS, "managed"); configuration.setProperty(AvailableSettings.USE_SQL_COMMENTS, Boolean.toString(dbConfig.isAutoCommentsEnabled())); configuration.setProperty(AvailableSettings.USE_GET_GENERATED_KEYS, "true"); configuration.setProperty(AvailableSettings.GENERATE_STATISTICS, "true"); configuration.setProperty(AvailableSettings.USE_REFLECTION_OPTIMIZER, "true"); configuration.setProperty(AvailableSettings.ORDER_UPDATES, "true"); configuration.setProperty(AvailableSettings.ORDER_INSERTS, "true"); configuration.setProperty(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true"); configuration.setProperty("jadira.usertype.autoRegisterUserTypes", "true"); for (Map.Entry<String, String> property : properties.entrySet()) { configuration.setProperty(property.getKey(), property.getValue()); } addAnnotatedClasses(configuration, entities); bundle.configure(configuration); final ServiceRegistry registry = new StandardServiceRegistryBuilder() .addService(ConnectionProvider.class, connectionProvider) .applySettings(configuration.getProperties()) .build(); configure(configuration, registry); return configuration.buildSessionFactory(registry); }
ssrb.applySettings( Collections.singletonMap( AvailableSettings.URL, newUrl ) ); StandardServiceRegistry ssr = ssrb.build();
public void testJpaJoinColumnPhysicalNaming() { final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder() .applySettings( Environment.getProperties() ) .build(); try {
protected SessionFactory sessionFactory(Map<String, Object> settings) { .applySettings( settings ) .build();
protected SessionFactory sessionFactory(Map<String, Object> settings) { .applySettings( settings ) .build();
.applySettings( settings ) .build();