BAEL-399 A Guide to Multitenancy in Hibernate 5 (#3323)

* BAEL-399: A Guide to Multitenancy in Hibernate 5

* Removed unused properties in profile 2

* Changes after code review
This commit is contained in:
Jose Carvajal 2018-01-01 00:28:27 +01:00 committed by KevinGilmore
parent 8de8770eec
commit 23f7f658e4
1 changed files with 7 additions and 8 deletions

View File

@ -8,12 +8,15 @@ import java.util.Properties;
import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
import org.hibernate.engine.jdbc.connections.spi.AbstractMultiTenantConnectionProvider;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.junit.Assert;
@SuppressWarnings("serial")
public class SchemaMultiTenantConnectionProvider extends AbstractMultiTenantConnectionProvider {
private final ConnectionProvider connectionProvider = initConnectionProvider();
private final ConnectionProvider connectionProvider;
public SchemaMultiTenantConnectionProvider() throws IOException {
connectionProvider = initConnectionProvider();
}
@Override
protected ConnectionProvider getAnyConnectionProvider() {
@ -33,13 +36,9 @@ public class SchemaMultiTenantConnectionProvider extends AbstractMultiTenantConn
return connection;
}
private ConnectionProvider initConnectionProvider() {
private ConnectionProvider initConnectionProvider() throws IOException {
Properties properties = new Properties();
try {
properties.load(getClass().getResourceAsStream("/hibernate-schema-multitenancy.properties"));
} catch (IOException e) {
Assert.fail("Error loading resource. Cause: " + e.getMessage());
}
properties.load(getClass().getResourceAsStream("/hibernate-schema-multitenancy.properties"));
DriverManagerConnectionProviderImpl connectionProvider = new DriverManagerConnectionProviderImpl();
connectionProvider.configure(properties);