Search in sources :

Example 1 with Configurable

use of org.hibernate.service.spi.Configurable in project hibernate-orm by hibernate.

the class BaseTransactionIsolationConfigTest method testSettingIsolationAsName.

@Test
public void testSettingIsolationAsName() throws Exception {
    Properties properties = Environment.getProperties();
    augmentConfigurationSettings(properties);
    properties.put(AvailableSettings.ISOLATION, "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();
    }
}
Also used : Startable(org.hibernate.service.spi.Startable) Connection(java.sql.Connection) Stoppable(org.hibernate.service.spi.Stoppable) Configurable(org.hibernate.service.spi.Configurable) Properties(java.util.Properties) ConnectionProvider(org.hibernate.engine.jdbc.connections.spi.ConnectionProvider) Test(org.junit.Test)

Example 2 with Configurable

use of org.hibernate.service.spi.Configurable in project hibernate-orm by hibernate.

the class ConnectionProviderDelegate method configure.

@Override
public void configure(Map configurationValues) {
    @SuppressWarnings("unchecked") Map<String, Object> settings = new HashMap<>(configurationValues);
    settings.remove(AvailableSettings.CONNECTION_PROVIDER);
    connectionProvider = ConnectionProviderInitiator.INSTANCE.initiateService(settings, serviceRegistry);
    if (connectionProvider instanceof Configurable) {
        Configurable configurableConnectionProvider = (Configurable) connectionProvider;
        configurableConnectionProvider.configure(settings);
    }
}
Also used : HashMap(java.util.HashMap) Configurable(org.hibernate.service.spi.Configurable)

Example 3 with Configurable

use of org.hibernate.service.spi.Configurable in project hibernate-orm by hibernate.

the class BaseTransactionIsolationConfigTest method testSettingIsolationAsNameAlt.

@Test
public void testSettingIsolationAsNameAlt() throws Exception {
    Properties properties = Environment.getProperties();
    augmentConfigurationSettings(properties);
    properties.put(AvailableSettings.ISOLATION, "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();
    }
}
Also used : Startable(org.hibernate.service.spi.Startable) Connection(java.sql.Connection) Stoppable(org.hibernate.service.spi.Stoppable) Configurable(org.hibernate.service.spi.Configurable) Properties(java.util.Properties) ConnectionProvider(org.hibernate.engine.jdbc.connections.spi.ConnectionProvider) Test(org.junit.Test)

Example 4 with Configurable

use of org.hibernate.service.spi.Configurable in project hibernate-orm by hibernate.

the class BaseTransactionIsolationConfigTest method testSettingIsolationAsNumericString.

@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();
    }
}
Also used : Startable(org.hibernate.service.spi.Startable) Connection(java.sql.Connection) Stoppable(org.hibernate.service.spi.Stoppable) Configurable(org.hibernate.service.spi.Configurable) Properties(java.util.Properties) ConnectionProvider(org.hibernate.engine.jdbc.connections.spi.ConnectionProvider) Test(org.junit.Test)

Example 5 with Configurable

use of org.hibernate.service.spi.Configurable in project hibernate-orm by hibernate.

the class BaseTransactionIsolationConfigTest method testSettingIsolationAsNumeric.

@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();
    }
}
Also used : Startable(org.hibernate.service.spi.Startable) Connection(java.sql.Connection) Stoppable(org.hibernate.service.spi.Stoppable) Configurable(org.hibernate.service.spi.Configurable) Properties(java.util.Properties) ConnectionProvider(org.hibernate.engine.jdbc.connections.spi.ConnectionProvider) Test(org.junit.Test)

Aggregations

Configurable (org.hibernate.service.spi.Configurable)5 Connection (java.sql.Connection)4 Properties (java.util.Properties)4 ConnectionProvider (org.hibernate.engine.jdbc.connections.spi.ConnectionProvider)4 Startable (org.hibernate.service.spi.Startable)4 Stoppable (org.hibernate.service.spi.Stoppable)4 Test (org.junit.Test)4 HashMap (java.util.HashMap)1