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

public abstract Class AbstractMultiTenantConnectionProvider<T>

extends Object
implements MultiTenantConnectionProvider<T>
Class Inheritance
All Implemented Interfaces
org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider, org.hibernate.service.spi.Wrapped, org.hibernate.service.Service, java.io.Serializable
Imports
java.sql.Connection, .SQLException, org.hibernate.service.UnknownUnwrapTypeException

Basic support for MultiTenantConnectionProvider implementations using individual ConnectionProvider instances per tenant behind the scenes.

This class is meant to be subclassed to implement application-specific requirements.

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).
protected abstract ConnectionProvider
public Connection
getConnection(T
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 use according to the underlying strategy of this provider.
public boolean
isUnwrappableAs(Class<?>
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(T
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 ConnectionProvider
selectConnectionProvider(T tenantIdentifier)

public boolean
supportsAggressiveRelease()

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

Does this connection provider support aggressive release of JDBC connections and later re-acquisition of those connections if needed?
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

AbstractMultiTenantConnectionProviderback to summary
public AbstractMultiTenantConnectionProvider()

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
getAnyConnectionProviderback to summary
protected abstract ConnectionProvider getAnyConnectionProvider()
getConnectionback to summary
public Connection getConnection(T 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 use according to the underlying strategy of this provider.

Parameters
tenantIdentifier:T

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<?> 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<?>

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(T 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:T

The identifier of the tenant.

connection:Connection

The JDBC connection to release

Annotations
@Override
Exceptions
SQLException:
Indicates a problem closing the connection
selectConnectionProviderback to summary
protected abstract ConnectionProvider selectConnectionProvider(T 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 later re-acquisition of those connections if needed?

This is used in conjunction with org.hibernate.ConnectionReleaseMode#AFTER_STATEMENT 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