public class DataSourceBasedMultiTenantConnectionProvider
extends org.hibernate.engine.jdbc.connections.spi.AbstractDataSourceBasedMultiTenantConnectionProviderImpl
implements org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider
MultiTenantConnectionProvider
that creates tenant aware connections based on tenant id to
datasource mappingConstructor and Description |
---|
DataSourceBasedMultiTenantConnectionProvider(DataSource masterDataSource,
String providerTenantId)
Creates new datasource based multitenant connection provider with the specified master datasource that will be
used out of the tenant context and (optionally) in the provider tenant context
|
Modifier and Type | Method and Description |
---|---|
void |
add(String tenantId,
DataSource dataSource)
Associates the specified datasource with the specified tenant id
|
DataSource |
remove(String tenantId)
Removes mapping to a datasource for the specified tenant id
|
DataSource |
selectAnyDataSource() |
DataSource |
selectDataSource(String tenantId) |
getAnyConnection, getConnection, isUnwrappableAs, releaseAnyConnection, releaseConnection, supportsAggressiveRelease, unwrap
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public DataSourceBasedMultiTenantConnectionProvider(@Nonnull DataSource masterDataSource, @Nullable String providerTenantId)
masterDataSource
- master datasource out of the tenant contextproviderTenantId
- tenant id to additionally map the master datasource to (optional)public void add(@Nonnull String tenantId, @Nonnull DataSource dataSource)
After this operation datasource can be resolved in that tenant context
tenantId
- tenant id with which the specified datasource is to be associateddataSource
- datasource to be associated with the specified tenant id@Nullable public DataSource remove(@Nonnull String tenantId)
After this operation datasource will be no longer resolvable in that tenant context
tenantId
- tenant id to remove the datasource mapping for@Nonnull public DataSource selectAnyDataSource()
selectAnyDataSource
in class org.hibernate.engine.jdbc.connections.spi.AbstractDataSourceBasedMultiTenantConnectionProviderImpl
@Nonnull public DataSource selectDataSource(@Nullable String tenantId)
selectDataSource
in class org.hibernate.engine.jdbc.connections.spi.AbstractDataSourceBasedMultiTenantConnectionProviderImpl
Copyright © 2019 SAP SE. All rights reserved.