Refine search
@Override protected Map getConfig() { Map config = super.getConfig(); String url = Environment.getProperties().getProperty( Environment.URL ); Properties connectionProps = new Properties(); connectionProps.put("user", Environment.getProperties().getProperty( Environment.USER )); connectionProps.put("password", Environment.getProperties().getProperty( Environment.PASS )); BaseDataSource dataSource = new BaseDataSource() { @Override public Connection getConnection() throws SQLException { return DriverManager.getConnection(url, connectionProps); } @Override public Connection getConnection(String username, String password) throws SQLException { return DriverManager.getConnection(url, connectionProps); } }; connectionProvider = new ConnectionProviderDecorator( dataSource ); config.put( AvailableSettings.CONNECTION_PROVIDER, connectionProvider ); return config; }
if ( hasCustomAccessors || !Environment.useReflectionOptimizer() ) { optimizer = null; optimizer = Environment.getBytecodeProvider().getReflectionOptimizer( mappedClass, getterNames,
@Override public boolean useStreamForLobBinding() { if ( useStreamForLobBinding == null ) { useStreamForLobBinding = Environment.useStreamsForBinary() || getJdbcServices().getJdbcEnvironment().getDialect().useInputStreamToInsertBlob(); } return useStreamForLobBinding; }
protected void init(boolean audited, String auditStrategy) throws IOException { this.audited = audited; Properties configurationProperties = new Properties(); configurationProperties.putAll( Environment.getProperties() ); if ( !audited ) { configurationProperties.setProperty( EnversIntegrator.AUTO_REGISTER, "false" ); } if ( createSchema() ) { configurationProperties.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); configurationProperties.setProperty( Environment.USE_NEW_ID_GENERATOR_MAPPINGS, "true" ); configurationProperties.setProperty( EnversSettings.USE_REVISION_ENTITY_WITH_NATIVE_ID, "false" ); } if ( auditStrategy != null && !"".equals( auditStrategy ) ) { configurationProperties.setProperty( "org.hibernate.envers.audit_strategy", auditStrategy ); } addConfigurationProperties( configurationProperties ); configurationProperties.put( AvailableSettings.LOADED_CLASSES, Arrays.asList( getAnnotatedClasses() ) ); entityManagerFactoryBuilder = (EntityManagerFactoryBuilderImpl) Bootstrap.getEntityManagerFactoryBuilder( new PersistenceUnitDescriptorAdapter(), configurationProperties ); emf = entityManagerFactoryBuilder.build().unwrap( HibernateEntityManagerFactory.class ); serviceRegistry = (StandardServiceRegistryImpl) emf.getSessionFactory() .getServiceRegistry() .getParentServiceRegistry(); newEntityManager(); }
public void configure(Properties props) throws HibernateException { String driverClass = props.getProperty(Environment.DRIVER); log.info( "JDBC isolation level: " + Environment.isolationLevelToString( isolation.intValue() ) ); url = props.getProperty( Environment.URL ); if ( url == null ) { String msg = "JDBC URL was not specified by property " + Environment.URL;
/** * Get an instance of the dialect specified by the current <tt>System</tt> properties. * * @return The specified Dialect * @throws HibernateException If no dialect was specified, or if it could not be instantiated. */ public static Dialect getDialect() throws HibernateException { return instantiateDialect( Environment.getProperties().getProperty( Environment.DIALECT ) ); }
super(); String storageEngine = Environment.getProperties().getProperty( Environment.STORAGE_ENGINE ); if(storageEngine == null) { storageEngine = System.getProperty( Environment.STORAGE_ENGINE ); getDefaultProperties().setProperty( Environment.MAX_FETCH_DEPTH, "2" ); getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
@Test public void testSettingIsolationAsNumericString() throws Exception { Properties properties = Environment.getProperties(); augmentConfigurationSettings( properties ); properties.put( AvailableSettings.ISOLATION, Integer.toString( Connection.TRANSACTION_SERIALIZABLE ) ); ConnectionProvider provider = getConnectionProviderUnderTest(); try { ( (Configurable) provider ).configure( properties ); if ( Startable.class.isInstance( provider ) ) { ( (Startable) provider ).start(); } Connection connection = provider.getConnection(); assertEquals( Connection.TRANSACTION_SERIALIZABLE, connection.getTransactionIsolation() ); provider.closeConnection( connection ); } finally { ( (Stoppable) provider ).stop(); } }
private void addProperties(Element parent) { Iterator iter = parent.elementIterator( "property" ); while ( iter.hasNext() ) { Element node = ( Element ) iter.next(); String name = node.attributeValue( "name" ); String value = node.getText().trim(); log.debug( name + "=" + value ); properties.setProperty( name, value ); if ( !name.startsWith( "hibernate" ) ) properties.setProperty( "hibernate." + name, value ); } Environment.verifyProperties( properties ); }
@Test public void testExtractSequenceInformationForSqlServerWithCaseSensitiveCollation() { String databaseNameToken = "databaseName="; String url = (String) Environment.getProperties().get( AvailableSettings.URL ); String[] tokens = url.split( databaseNameToken ); String newUrl = tokens[0] + databaseNameToken + DATABASE_NAME;
/** * Create a builder with the specified bootstrap services. * * @param bootstrapServiceRegistry Provided bootstrap registry to use. */ public StandardServiceRegistryBuilder( BootstrapServiceRegistry bootstrapServiceRegistry, LoadedConfig loadedConfigBaseline) { this.settings = Environment.getProperties(); this.bootstrapServiceRegistry = bootstrapServiceRegistry; this.configLoader = new ConfigLoader( bootstrapServiceRegistry ); this.aggregatedCfgXml = loadedConfigBaseline; }
public ProxiedInstantiator(Class componentClass) { proxiedClass = componentClass; if ( proxiedClass.isInterface() ) { factory = Environment.getBytecodeProvider() .getProxyFactoryFactory() .buildBasicProxyFactory( null, new Class[] { proxiedClass } ); } else { factory = Environment.getBytecodeProvider() .getProxyFactoryFactory() .buildBasicProxyFactory( proxiedClass, null ); } }
public Object get(ResultSet rs, String name) throws HibernateException, SQLException { Timestamp ts = rs.getTimestamp(name); if (ts!=null) { Calendar cal = new GregorianCalendar(); if ( Environment.jvmHasTimestampBug() ) { cal.setTime( new Date( ts.getTime() + ts.getNanos() / 1000000 ) ); } else { cal.setTime(ts); } return cal; } else { return null; } }
/** * Build the service registry accounting for all settings and service initiators and services. * * @return The built service registry */ public ServiceRegistry buildServiceRegistry() { Map<?,?> settingsCopy = new HashMap(); settingsCopy.putAll( settings ); Environment.verifyProperties( settingsCopy ); ConfigurationHelper.resolvePlaceHolders( settingsCopy ); for ( Integrator integrator : bootstrapServiceRegistry.getService( IntegratorService.class ).getIntegrators() ) { if ( ServiceContributingIntegrator.class.isInstance( integrator ) ) { ServiceContributingIntegrator.class.cast( integrator ).prepareServices( this ); } } return new StandardServiceRegistryImpl( bootstrapServiceRegistry, initiators, providedServices, settingsCopy ); }
public static BytecodeProvider buildBytecodeProvider(Properties properties) { String provider = ConfigurationHelper.getString( BYTECODE_PROVIDER, properties, BYTECODE_PROVIDER_NAME_DEFAULT ); return buildBytecodeProvider( provider ); }
if (log.isDebugEnabled()) { log.debug("JDBC isolation level: " + Environment.isolationLevelToString(isolation));
if ( hasCustomAccessors || !Environment.useReflectionOptimizer() ) { fastClass = null; optimizer = null;
public void configure(Properties props) throws HibernateException { String driverClass = props.getProperty(Environment.DRIVER); log.info( "JDBC isolation level: " + Environment.isolationLevelToString( isolation.intValue() ) ); url = props.getProperty(Environment.URL); if (url==null) { String msg = "JDBC URL was not specified by property " + Environment.URL;
@Override protected DataSource dataSource() { DataSource dataSource = ReflectionUtil.newInstance( "org.postgresql.ds.PGSimpleDataSource" ); ReflectionUtil.setProperty( dataSource, "url", Environment.getProperties().getProperty( AvailableSettings.URL ) ); ReflectionUtil.setProperty( dataSource, "user", Environment.getProperties().getProperty( AvailableSettings.USER ) ); ReflectionUtil.setProperty( dataSource, "password", Environment.getProperties().getProperty( AvailableSettings.PASS ) ); return dataSource; } }
@Test public void testSettingIsolationAsNumeric() throws Exception { Properties properties = Environment.getProperties(); augmentConfigurationSettings( properties ); properties.put( AvailableSettings.ISOLATION, Connection.TRANSACTION_SERIALIZABLE ); ConnectionProvider provider = getConnectionProviderUnderTest(); try { ( (Configurable) provider ).configure( properties ); if ( Startable.class.isInstance( provider ) ) { ( (Startable) provider ).start(); } Connection connection = provider.getConnection(); assertEquals( Connection.TRANSACTION_SERIALIZABLE, connection.getTransactionIsolation() ); provider.closeConnection( connection ); } finally { ( (Stoppable) provider ).stop(); } }