HHH-13700 Configuration property CONNECTION_PROVIDER_DISABLES_AUTOCOMMIT should not be passed to the JDBC connection properties
This commit is contained in:
parent
2bcb1b0a6d
commit
cec7329214
|
@ -124,4 +124,13 @@ public abstract class BasicConnectionCreator implements ConnectionCreator {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Connection makeConnection(String url, Properties connectionProps);
|
protected abstract Connection makeConnection(String url, Properties connectionProps);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exposed for testing purposes only.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Properties getConnectionProperties() {
|
||||||
|
return new Properties( connectionProps );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -417,6 +417,7 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator<Con
|
||||||
SPECIAL_PROPERTIES.add( AvailableSettings.ISOLATION );
|
SPECIAL_PROPERTIES.add( AvailableSettings.ISOLATION );
|
||||||
SPECIAL_PROPERTIES.add( AvailableSettings.DRIVER );
|
SPECIAL_PROPERTIES.add( AvailableSettings.DRIVER );
|
||||||
SPECIAL_PROPERTIES.add( AvailableSettings.USER );
|
SPECIAL_PROPERTIES.add( AvailableSettings.USER );
|
||||||
|
SPECIAL_PROPERTIES.add( AvailableSettings.CONNECTION_PROVIDER_DISABLES_AUTOCOMMIT );
|
||||||
|
|
||||||
ISOLATION_VALUE_MAP = new ConcurrentHashMap<String, Integer>();
|
ISOLATION_VALUE_MAP = new ConcurrentHashMap<String, Integer>();
|
||||||
ISOLATION_VALUE_MAP.put( "TRANSACTION_NONE", Connection.TRANSACTION_NONE );
|
ISOLATION_VALUE_MAP.put( "TRANSACTION_NONE", Connection.TRANSACTION_NONE );
|
||||||
|
|
|
@ -215,6 +215,16 @@ public class DriverManagerConnectionProviderImpl
|
||||||
}
|
}
|
||||||
//CHECKSTYLE:END_ALLOW_FINALIZER
|
//CHECKSTYLE:END_ALLOW_FINALIZER
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exposed to facilitate testing only.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Properties getConnectionProperties() {
|
||||||
|
BasicConnectionCreator connectionCreator = (BasicConnectionCreator) this.state.pool.connectionCreator;
|
||||||
|
return connectionCreator.getConnectionProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class PooledConnections {
|
public static class PooledConnections {
|
||||||
|
|
||||||
private final ConcurrentLinkedQueue<Connection> allConnections = new ConcurrentLinkedQueue<Connection>();
|
private final ConcurrentLinkedQueue<Connection> allConnections = new ConcurrentLinkedQueue<Connection>();
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
package org.hibernate.jpa.test.connection;
|
package org.hibernate.jpa.test.connection;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
@ -15,10 +16,13 @@ import javax.persistence.criteria.CriteriaBuilder;
|
||||||
import javax.persistence.criteria.CriteriaQuery;
|
import javax.persistence.criteria.CriteriaQuery;
|
||||||
|
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
|
||||||
|
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||||
import org.hibernate.exception.SQLGrammarException;
|
import org.hibernate.exception.SQLGrammarException;
|
||||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,6 +50,19 @@ public class TestConnectionPool
|
||||||
AvailableSettings.POOL_SIZE,
|
AvailableSettings.POOL_SIZE,
|
||||||
Integer.valueOf( CONNECTION_POOL_SIZE )
|
Integer.valueOf( CONNECTION_POOL_SIZE )
|
||||||
);
|
);
|
||||||
|
options.put( "hibernate.connection.customProperty", "x" );
|
||||||
|
options.put( AvailableSettings.CONNECTION_PROVIDER_DISABLES_AUTOCOMMIT, "true" );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestForIssue(jiraKey = "HHH-13700")
|
||||||
|
public void testConnectionPoolPropertyFiltering() {
|
||||||
|
ConnectionProvider cp = serviceRegistry().getService( ConnectionProvider.class );
|
||||||
|
DriverManagerConnectionProviderImpl dmcp = (DriverManagerConnectionProviderImpl) cp;
|
||||||
|
Properties connectionProperties = dmcp.getConnectionProperties();
|
||||||
|
Assert.assertEquals( "x", connectionProperties.getProperty( "customProperty" ) );
|
||||||
|
Assert.assertNull( connectionProperties.getProperty( "pool_size" ) );
|
||||||
|
Assert.assertNull( connectionProperties.getProperty( "provider_disables_autocommit" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue