Top Description Constructors Methods
org.hibernate.engine.jdbc.connections.spi

public abstract Class AbstractDataSourceBasedMultiTenantConnectionProviderImpl

extends Object
implements MultiTenantConnectionProvider
Class Inheritance
All Implemented Interfaces
org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider, org.hibernate.service.spi.Wrapped, org.hibernate.service.Service, java.io.Serializable
Known Direct Subclasses
org.hibernate.engine.jdbc.connections.spi.DataSourceBasedMultiTenantConnectionProviderImpl
Imports
java.sql.Connection, .SQLException, javax.sql.DataSource, org.hibernate.service.UnknownUnwrapTypeException

Basic support for implementations of MultiTenantConnectionProvider based on DataSources.
Author
Steve Ebersole

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Connection
getAnyConnection()

Implements org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider.getAnyConnection.

Allows access to the database metadata of the underlying database(s) in situations where we do not have a tenant id (like startup processing, for example).
public Connection
getConnection(String
The identifier of the tenant for which to get a connection
tenantIdentifier
)

Implements org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider.getConnection.

Obtains a connection for Hibernate use according to the underlying strategy of this provider.
public boolean
isUnwrappableAs(Class<T>
The type to check.
unwrapType
)

Implements org.hibernate.service.spi.Wrapped.isUnwrappableAs.

Can this wrapped service be unwrapped as the indicated type?
public void
releaseAnyConnection(Connection
The JDBC connection to release
connection
)

Implements org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider.releaseAnyConnection.

Release a connection obtained from getAnyConnection
public void
releaseConnection(String
The identifier of the tenant.
tenantIdentifier
,
Connection
The JDBC connection to release
connection
)

Implements org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider.releaseConnection.

Release a connection from Hibernate use.
protected abstract DataSource
protected abstract DataSource
selectDataSource(String tenantIdentifier)

public boolean
supportsAggressiveRelease()

Implements org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider.supportsAggressiveRelease.

Does this connection provider support aggressive release of JDBC connections and re-acquisition of those connections (if need be) later?
public <T> T
unwrap(Class<T>
The java type as which to unwrap this instance.
unwrapType
)

Implements org.hibernate.service.spi.Wrapped.unwrap.

Unproxy the service proxy
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

AbstractDataSourceBasedMultiTenantConnectionProviderImplback to summary
public AbstractDataSourceBasedMultiTenantConnectionProviderImpl()

Method Detail

getAnyConnectionback to summary
public Connection getAnyConnection() throws SQLException

Implements org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider.getAnyConnection.

Doc from org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider.getAnyConnection.

Allows access to the database metadata of the underlying database(s) in situations where we do not have a tenant id (like startup processing, for example).

Returns:Connection

The database metadata.

Annotations
@Override
Exceptions
SQLException:
Indicates a problem opening a connection
getConnectionback to summary
public Connection getConnection(String tenantIdentifier) throws SQLException

Implements org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider.getConnection.

Doc from org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider.getConnection.

Obtains a connection for Hibernate use according to the underlying strategy of this provider.

Parameters
tenantIdentifier:String

The identifier of the tenant for which to get a connection

Returns:Connection

The obtained JDBC connection

Annotations
@Override
Exceptions
SQLException:
Indicates a problem opening a connection
isUnwrappableAsback to summary
public boolean isUnwrappableAs(Class<T> unwrapType)

Implements org.hibernate.service.spi.Wrapped.isUnwrappableAs.

Doc from org.hibernate.service.spi.Wrapped.isUnwrappableAs.

Can this wrapped service be unwrapped as the indicated type?

Parameters
unwrapType:Class<T>

The type to check.

Returns:boolean

True/false.

Annotations
@Override
releaseAnyConnectionback to summary
public void releaseAnyConnection(Connection connection) throws SQLException

Implements org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider.releaseAnyConnection.

Doc from org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider.releaseAnyConnection.

Release a connection obtained from getAnyConnection

Parameters
connection:Connection

The JDBC connection to release

Annotations
@Override
Exceptions
SQLException:
Indicates a problem closing the connection
releaseConnectionback to summary
public void releaseConnection(String tenantIdentifier, Connection connection) throws SQLException

Implements org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider.releaseConnection.

Doc from org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider.releaseConnection.

Release a connection from Hibernate use.

Parameters
tenantIdentifier:String

The identifier of the tenant.

connection:Connection

The JDBC connection to release

Annotations
@Override
Exceptions
SQLException:
Indicates a problem closing the connection
selectAnyDataSourceback to summary
protected abstract DataSource selectAnyDataSource()
selectDataSourceback to summary
protected abstract DataSource selectDataSource(String tenantIdentifier)
supportsAggressiveReleaseback to summary
public boolean supportsAggressiveRelease()

Implements org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider.supportsAggressiveRelease.

Doc from org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider.supportsAggressiveRelease.

Does this connection provider support aggressive release of JDBC connections and re-acquisition of those connections (if need be) later?

This is used in conjunction with org.hibernate.cfg.Environment#RELEASE_CONNECTIONS to aggressively release JDBC connections. However, the configured ConnectionProvider must support re-acquisition of the same underlying connection for that semantic to work.

Typically, this is only true in managed environments where a container tracks connections by transaction or thread. Note that JTA semantic depends on the fact that the underlying connection provider does support aggressive release.

Returns:boolean

true if aggressive releasing is supported; false otherwise.

Annotations
@Override
unwrapback to summary
public <T> T unwrap(Class<T> unwrapType)

Implements org.hibernate.service.spi.Wrapped.unwrap.

Doc from org.hibernate.service.spi.Wrapped.unwrap.

Unproxy the service proxy

Parameters
unwrapType:Class<T>

The java type as which to unwrap this instance.

Returns:T

The unwrapped reference

Annotations
@Override
@SuppressWarnings:unchecked