Fix MultiTenantConnectionProvider implementations in Hibernate examples.
This commit is contained in:
@@ -42,17 +42,6 @@ public class NoOpConnectionProvider implements MultiTenantConnectionProvider, Hi
|
||||
connection.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection getConnection(String schema) throws SQLException {
|
||||
|
||||
return dataSource.getConnection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseConnection(String s, Connection connection) throws SQLException {
|
||||
connection.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsAggressiveRelease() {
|
||||
return false;
|
||||
@@ -72,4 +61,18 @@ public class NoOpConnectionProvider implements MultiTenantConnectionProvider, Hi
|
||||
public void customize(Map<String, Object> hibernateProperties) {
|
||||
hibernateProperties.put(AvailableSettings.MULTI_TENANT_CONNECTION_PROVIDER, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection getConnection(Object tenantIdentifier) throws SQLException {
|
||||
return dataSource.getConnection();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider#releaseConnection(java.lang.Object, java.sql.Connection)
|
||||
*/
|
||||
@Override
|
||||
public void releaseConnection(Object tenantIdentifier, Connection connection) throws SQLException {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,14 +43,20 @@ public class ExampleConnectionProvider implements MultiTenantConnectionProvider,
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection getConnection(String schema) throws SQLException {
|
||||
public Connection getConnection(Object tenantIdentifier) throws SQLException {
|
||||
|
||||
final Connection connection = dataSource.getConnection();
|
||||
connection.setSchema(schema);
|
||||
connection.setSchema(tenantIdentifier.toString());
|
||||
return connection;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider#releaseConnection(java.lang.Object, java.sql.Connection)
|
||||
*/
|
||||
@Override
|
||||
public void releaseConnection(String s, Connection connection) throws SQLException {
|
||||
public void releaseConnection(Object tenantIdentifier, Connection connection) throws SQLException {
|
||||
|
||||
connection.setSchema("PUBLIC");
|
||||
connection.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user