Search in sources :

Example 41 with ConnectionProvider

use of org.hibernate.engine.jdbc.connections.spi.ConnectionProvider 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(PropertiesHelper.map(properties));
        if (provider instanceof Startable) {
            ((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

ConnectionProvider (org.hibernate.engine.jdbc.connections.spi.ConnectionProvider)41 Test (org.junit.Test)23 Connection (java.sql.Connection)13 TestForIssue (org.hibernate.testing.TestForIssue)11 EntityManagerFactory (jakarta.persistence.EntityManagerFactory)10 HibernatePersistenceProvider (org.hibernate.jpa.HibernatePersistenceProvider)10 DataSource (javax.sql.DataSource)9 DataSourceStub (org.hibernate.testing.jdbc.DataSourceStub)9 PersistenceUnitInfoAdapter (org.hibernate.testing.util.jpa.PersistenceUnitInfoAdapter)9 PersistenceProvider (jakarta.persistence.spi.PersistenceProvider)8 HashMap (java.util.HashMap)8 Map (java.util.Map)7 Properties (java.util.Properties)6 MetadataSources (org.hibernate.boot.MetadataSources)6 DriverManagerConnectionProviderImpl (org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl)6 Test (org.junit.jupiter.api.Test)6 SQLException (java.sql.SQLException)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)5 DatasourceConnectionProviderImpl (org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl)5