HHH-9697 - Complete documentation of new approach and APIs for SessionFactory building
This commit is contained in:
parent
148159fadc
commit
7715fccd04
|
@ -46,7 +46,8 @@ If you wish to alter how the `BootstrapServiceRegistry` is built, you would use
|
|||
====
|
||||
[source, JAVA]
|
||||
----
|
||||
BootstrapServiceRegistryBuilder bootstrapRegistryBuilder = new BootstrapServiceRegistryBuilder();
|
||||
BootstrapServiceRegistryBuilder bootstrapRegistryBuilder
|
||||
= new BootstrapServiceRegistryBuilder();
|
||||
// add a special ClassLoader
|
||||
bootstrapRegistryBuilder.applyClassLoader( mySpecialClassLoader );
|
||||
// manually add an Integrator
|
||||
|
@ -73,7 +74,8 @@ one of 2 ways:
|
|||
[source, JAVA]
|
||||
----
|
||||
BootstrapServiceRegistry bootstrapRegistry = ...;
|
||||
StandardServiceRegistryBuilder standardRegistryBuilder = new StandardServiceRegistryBuilder( bootstrapRegistry );
|
||||
StandardServiceRegistryBuilder standardRegistryBuilder
|
||||
= new StandardServiceRegistryBuilder( bootstrapRegistry );
|
||||
----
|
||||
====
|
||||
|
||||
|
@ -82,7 +84,8 @@ one of 2 ways:
|
|||
====
|
||||
[source, JAVA]
|
||||
----
|
||||
StandardServiceRegistryBuilder standardRegistryBuilder = new StandardServiceRegistryBuilder();
|
||||
StandardServiceRegistryBuilder standardRegistryBuilder
|
||||
= new StandardServiceRegistryBuilder();
|
||||
----
|
||||
====
|
||||
|
||||
|
@ -118,8 +121,8 @@ A `StandardServiceRegistry` is also highly configurable via the `StandardService
|
|||
|
||||
The `org.hibernate.boot.Metadata` object contains the parsed representations of an application's
|
||||
domain model and its mapping to a database. The first thing we obviously need to build a parsed
|
||||
representation is the source information to be parsed. This is the purpose of
|
||||
`org.hibernate.boot.MetadataSources`.
|
||||
representation is the source information to be parsed (annotated classes, `hbm.xml` files, `orm.xml` files). This is
|
||||
the purpose of `org.hibernate.boot.MetadataSources`.
|
||||
|
||||
|
||||
[[MetadataSources-example]]
|
||||
|
@ -168,7 +171,7 @@ all methods on `MetadataSources` allow for chaining should you prefer that style
|
|||
====
|
||||
|
||||
Once we have the sources of mapping information defined, we need to build the `Metadata` object. If you are
|
||||
ok with the default behavior in building the `Metadata` (or if relying on a `MetadataBuilderContributor` - see below)
|
||||
ok with the default behavior in building the `Metadata` (or if relying on a `MetadataBuilderInitializer` - see below)
|
||||
then you can simply call `MetadataSources#buildMetadata`.
|
||||
|
||||
NOTE : Notice that a ServiceRegistry can be passed at a number of points in this bootstrapping process. The suggested
|
||||
|
@ -227,6 +230,38 @@ over the `SessionFactory` building process.
|
|||
|
||||
== Putting It All Together
|
||||
|
||||
The bootstrapping API is quite flexible, but in most cases it makes the most sense to think of
|
||||
it as a 3 step process:
|
||||
|
||||
1. Build the `StandardServiceRegistry`
|
||||
2. Build the `Metadata`
|
||||
3. Use those 2 things to build the `SessionFactory`
|
||||
|
||||
[[Putting-It-All-Together-ex1]]
|
||||
.Building SessionFactory via SessionFactoryBuilder
|
||||
====
|
||||
[source, JAVA]
|
||||
----
|
||||
StandardServiceRegistry standardRegistry = new StandardServiceRegistryBuilder()
|
||||
.configure( "org/hibernate/example/MyCfg.xml" )
|
||||
.build();
|
||||
|
||||
Metadata metadata = new MetadataSources( standardRegistry )
|
||||
.addAnnotatedClass( MyEntity.class )
|
||||
.addAnnotatedClassName( "org.hibernate.example.Customer" )
|
||||
.addResource( "org/hibernate/example/Order.hbm.xml" )
|
||||
.addResource( "org/hibernate/example/Product.orm.xml" )
|
||||
.getMetadataBuilder()
|
||||
.applyImplicitNamingStrategy( ImplicitNamingStrategyJpaCompliantImpl.INSTANCE )
|
||||
.build();
|
||||
|
||||
SessionFactory sessionFactory = metadata.getSessionFactoryBuilder()
|
||||
.applyBeanManager( getBeanManagerFromSomewhere() )
|
||||
.build();
|
||||
----
|
||||
====
|
||||
|
||||
|
||||
== Integration Points
|
||||
|
||||
=== Integrator
|
||||
|
@ -234,6 +269,5 @@ over the `SessionFactory` building process.
|
|||
=== TypeContributor
|
||||
=== MetadataSourcesContributor
|
||||
=== MetadataBuilderInitializer
|
||||
=== SessionFactoryBuilderFactory
|
||||
=== SessionFactoryBuilderInitializer (todo)
|
||||
=== SessionFactoryObserver
|
|
@ -25,8 +25,8 @@ NOTE: This is still very much a work in progress. <<helping,Help>> is definitely
|
|||
|
||||
|
||||
== Integrator Guides
|
||||
|
||||
* The <<registries/ServiceRegistries.adoc#,Service Registries Guide>> discusses Hibernate Service and ServiceRegistry contracts.
|
||||
* Providers of custom `SessionFactory` implementations should see <<sessionfactory/CustomSessionFactory.adoc#,Custom SessionFactory and Session Implementations Guide>>
|
||||
* Others coming soon
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,131 @@
|
|||
= Custom SessionFactory and Session Implementations Guide
|
||||
:toc:
|
||||
|
||||
The two main contracts of Hibernate, `org.hibernate.SessionFactory` and `org.hibernate.Session`, are both
|
||||
defined as interfaces which allows for custom implementations to be provided. There are two high-leve ways
|
||||
in which custom implementations can be provided to users. The first is to develop a custom bootstrap API
|
||||
specific to the custom implementation. The second way is to integrate with Hibernate's bootstrapping API.
|
||||
This guide will cover the second approach.
|
||||
|
||||
|
||||
=== Implementor contracts
|
||||
|
||||
A Hibernate naming convention is that SPI contracts extending API contracts are named with Implementor appended
|
||||
to the API contract name. For `SessionFactory` and `Session` that is `SessionFactoryImplementor` and
|
||||
`SessionImplementor` respectively. These SPI contracts extra information and functionality needed by internal
|
||||
components as well as other SPI components. Therefore, custom `SessionFactory` and `Session` should additionally
|
||||
implement `org.hibernate.engine.spi.SessionFactoryImplementor` and `org.hibernate.engine.spi.SessionImplementor`.
|
||||
See all pertinent JavaDocs for discussions of implementation details.
|
||||
|
||||
|
||||
=== Integration hooks
|
||||
|
||||
`org.hibernate.boot.SessionFactoryBuilder` is part of the Hibernate native bootstrap API where we want to configure
|
||||
the `SessionFactory` to be built. Third parties can hook into this process by supplying a
|
||||
`org.hibernate.boot.spi.SessionFactoryBuilderFactory` via the Java ServiceLoader mechanism (see JavaDocs for
|
||||
`java.util.ServiceLoader` if you are unfamiliar with this service discovery mechanism). As you might guess from their
|
||||
names, a `SessionFactoryBuilderFactory` is responsible for creating `SessionFactoryBuilder` instances and a
|
||||
`SessionFactoryBuilder` is in turn responsible for creating `SessionFactory` instances.
|
||||
|
||||
`org.hibernate.boot.spi.SessionFactoryOptions` are the options ultimately passed to the `SessionFactory` being
|
||||
built. They represent the choices applied by the user via the `SessionFactoryBuilder` contract. Custom integrations
|
||||
can leverage this and the `SessionFactoryBuilder` to also expose custom option setting.
|
||||
|
||||
|
||||
[[example1]]
|
||||
.Custom SessionFactoryBuilderFactory with additional option
|
||||
====
|
||||
[source, JAVA]
|
||||
----
|
||||
public class CustomSessionFactoryBuilderFactory
|
||||
implements SessionFactoryBuilderFactory {
|
||||
@Override
|
||||
public SessionFactoryBuilder getSessionFactoryBuilder(
|
||||
MetadataImplementor metadata,
|
||||
SessionFactoryBuilderImplementor defaultBuilder) {
|
||||
return new CustomSessionFactoryBuilder( metadata, defaultBuilder );
|
||||
}
|
||||
}
|
||||
|
||||
public class CustomSessionFactoryBuilder
|
||||
extends AbstractDelegatingSessionFactoryBuilder {
|
||||
private final MetadataImplementor metadata;
|
||||
|
||||
private final boolean customSetting;
|
||||
|
||||
public DelegatingSessionFactoryBuilder(
|
||||
MetadataImplementor metadata,
|
||||
SessionFactoryBuilderImplementor delegate) {
|
||||
super( delegate );
|
||||
this.metadata = metadata;
|
||||
|
||||
// initialize customSetting, maybe based on config settings...
|
||||
ConfigurationService cfgService = metadata.getMetadataBuildingOptions()
|
||||
.getServiceRegistry()
|
||||
.getService( ConfigurationService.class );
|
||||
this.customSetting = cfgService.getSetting(
|
||||
"com.acme.domain.custom_setting",
|
||||
StandardConverters.BOOLEAN,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DelegatingSessionFactoryBuilder unwrap() {
|
||||
return (DelegatingSessionFactoryBuilder) this;
|
||||
}
|
||||
|
||||
public CustomSessionFactoryBuilder applyCustomSetting(boolean enabled) {
|
||||
this.customSetting = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactory build() {
|
||||
CustomSessionFactoryOptions options = new CustomSessionFactoryOptions(
|
||||
getDelegate().buildSessionFactoryOptions(),
|
||||
customSetting
|
||||
);
|
||||
return new CustomSessionFactory( metadata, options );
|
||||
}
|
||||
}
|
||||
|
||||
public class CustomSessionFactoryOptions
|
||||
extends AbstractDelegatingSessionFactoryOptions {
|
||||
private final boolean customSetting;
|
||||
|
||||
public CustomSessionFactoryOptions(
|
||||
SessionFactoryOptions baseOptions,
|
||||
boolean customSetting) {
|
||||
super( baseOptions );
|
||||
this.customSetting = customSetting;
|
||||
}
|
||||
|
||||
public boolean getCustomSetting() {
|
||||
return customSetting;
|
||||
}
|
||||
}
|
||||
----
|
||||
====
|
||||
|
||||
Users can then build your custom `SessionFactory` still using the normal Hibernate bootstrap. In fact,
|
||||
accepting defaults for your custom settings/options, their code does not even change. Of course they
|
||||
can also apply selections to your custom settings/options as well:
|
||||
|
||||
|
||||
|
||||
[[example2]]
|
||||
.Example usage
|
||||
====
|
||||
[source, JAVA]
|
||||
----
|
||||
Metadata metadata = ...;
|
||||
|
||||
// The SessionFactory returned here is concretely
|
||||
// a CustomSessionFactory
|
||||
SessionFactory sf = metadata.getSessionFactoryBuilder()
|
||||
.unwrap( CustomSessionFactoryBuilder.class )
|
||||
.applyCustomSetting( false )
|
||||
.buildSessionFactory();
|
||||
----
|
||||
====
|
|
@ -0,0 +1,379 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2015, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.boot.spi;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.ConnectionReleaseMode;
|
||||
import org.hibernate.CustomEntityDirtinessStrategy;
|
||||
import org.hibernate.EntityMode;
|
||||
import org.hibernate.EntityNameResolver;
|
||||
import org.hibernate.Interceptor;
|
||||
import org.hibernate.MultiTenancyStrategy;
|
||||
import org.hibernate.NullPrecedence;
|
||||
import org.hibernate.SessionFactoryObserver;
|
||||
import org.hibernate.boot.SessionFactoryBuilder;
|
||||
import org.hibernate.boot.TempTableDdlTransactionHandling;
|
||||
import org.hibernate.cache.spi.QueryCacheFactory;
|
||||
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
|
||||
import org.hibernate.dialect.function.SQLFunction;
|
||||
import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy;
|
||||
import org.hibernate.loader.BatchFetchStyle;
|
||||
import org.hibernate.proxy.EntityNotFoundDelegate;
|
||||
import org.hibernate.resource.jdbc.spi.StatementInspector;
|
||||
import org.hibernate.tuple.entity.EntityTuplizer;
|
||||
import org.hibernate.tuple.entity.EntityTuplizerFactory;
|
||||
|
||||
/**
|
||||
* Convenience base class for custom implementors of SessionFactoryBuilder, using delegation
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public abstract class AbstractDelegatingSessionFactoryBuilder implements SessionFactoryBuilder {
|
||||
private final SessionFactoryBuilder delegate;
|
||||
|
||||
public AbstractDelegatingSessionFactoryBuilder(SessionFactoryBuilder delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyValidatorFactory(Object validatorFactory) {
|
||||
delegate.applyValidatorFactory( validatorFactory );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyBeanManager(Object beanManager) {
|
||||
delegate.applyBeanManager( beanManager );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyName(String sessionFactoryName) {
|
||||
delegate.applyName( sessionFactoryName );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyNameAsJndiName(boolean isJndiName) {
|
||||
delegate.applyNameAsJndiName( isJndiName );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyAutoClosing(boolean enabled) {
|
||||
delegate.applyAutoClosing( enabled );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyAutoFlushing(boolean enabled) {
|
||||
delegate.applyAutoFlushing( enabled );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyStatisticsSupport(boolean enabled) {
|
||||
delegate.applyStatisticsSupport( enabled );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyInterceptor(Interceptor interceptor) {
|
||||
delegate.applyInterceptor( interceptor );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyStatementInspector(StatementInspector statementInspector) {
|
||||
delegate.applyStatementInspector( statementInspector );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder addSessionFactoryObservers(SessionFactoryObserver... observers) {
|
||||
delegate.addSessionFactoryObservers( observers );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyCustomEntityDirtinessStrategy(CustomEntityDirtinessStrategy strategy) {
|
||||
delegate.applyCustomEntityDirtinessStrategy( strategy );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder addEntityNameResolver(EntityNameResolver... entityNameResolvers) {
|
||||
delegate.addEntityNameResolver( entityNameResolvers );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyEntityNotFoundDelegate(EntityNotFoundDelegate entityNotFoundDelegate) {
|
||||
delegate.applyEntityNotFoundDelegate( entityNotFoundDelegate );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyIdentifierRollbackSupport(boolean enabled) {
|
||||
delegate.applyIdentifierRollbackSupport( enabled );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public SessionFactoryBuilder applyDefaultEntityMode(EntityMode entityMode) {
|
||||
delegate.applyDefaultEntityMode( entityMode );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyNullabilityChecking(boolean enabled) {
|
||||
delegate.applyNullabilityChecking( enabled );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyLazyInitializationOutsideTransaction(boolean enabled) {
|
||||
delegate.applyLazyInitializationOutsideTransaction( enabled );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyEntityTuplizerFactory(EntityTuplizerFactory entityTuplizerFactory) {
|
||||
delegate.applyEntityTuplizerFactory( entityTuplizerFactory );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyEntityTuplizer(
|
||||
EntityMode entityMode,
|
||||
Class<? extends EntityTuplizer> tuplizerClass) {
|
||||
delegate.applyEntityTuplizer( entityMode, tuplizerClass );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyMultiTableBulkIdStrategy(MultiTableBulkIdStrategy strategy) {
|
||||
delegate.applyMultiTableBulkIdStrategy( strategy );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyTempTableDdlTransactionHandling(TempTableDdlTransactionHandling handling) {
|
||||
delegate.applyTempTableDdlTransactionHandling( handling );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyBatchFetchStyle(BatchFetchStyle style) {
|
||||
delegate.applyBatchFetchStyle( style );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyDefaultBatchFetchSize(int size) {
|
||||
delegate.applyDefaultBatchFetchSize( size );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyMaximumFetchDepth(int depth) {
|
||||
delegate.applyMaximumFetchDepth( depth );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyDefaultNullPrecedence(NullPrecedence nullPrecedence) {
|
||||
delegate.applyDefaultNullPrecedence( nullPrecedence );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyOrderingOfInserts(boolean enabled) {
|
||||
delegate.applyOrderingOfInserts( enabled );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyOrderingOfUpdates(boolean enabled) {
|
||||
delegate.applyOrderingOfUpdates( enabled );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyMultiTenancyStrategy(MultiTenancyStrategy strategy) {
|
||||
delegate.applyMultiTenancyStrategy( strategy );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyCurrentTenantIdentifierResolver(CurrentTenantIdentifierResolver resolver) {
|
||||
delegate.applyCurrentTenantIdentifierResolver( resolver );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyJtaTrackingByThread(boolean enabled) {
|
||||
delegate.applyJtaTrackingByThread( enabled );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyPreferUserTransactions(boolean preferUserTransactions) {
|
||||
delegate.applyPreferUserTransactions( preferUserTransactions );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public SessionFactoryBuilder applyQuerySubstitutions(Map substitutions) {
|
||||
delegate.applyQuerySubstitutions( substitutions );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyStrictJpaQueryLanguageCompliance(boolean enabled) {
|
||||
delegate.applyStrictJpaQueryLanguageCompliance( enabled );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyNamedQueryCheckingOnStartup(boolean enabled) {
|
||||
delegate.applyNamedQueryCheckingOnStartup( enabled );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applySecondLevelCacheSupport(boolean enabled) {
|
||||
delegate.applySecondLevelCacheSupport( enabled );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyQueryCacheSupport(boolean enabled) {
|
||||
delegate.applyQueryCacheSupport( enabled );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyQueryCacheFactory(QueryCacheFactory factory) {
|
||||
delegate.applyQueryCacheFactory( factory );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyCacheRegionPrefix(String prefix) {
|
||||
delegate.applyCacheRegionPrefix( prefix );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyMinimalPutsForCaching(boolean enabled) {
|
||||
delegate.applyMinimalPutsForCaching( enabled );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyStructuredCacheEntries(boolean enabled) {
|
||||
delegate.applyStructuredCacheEntries( enabled );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyDirectReferenceCaching(boolean enabled) {
|
||||
delegate.applyDirectReferenceCaching( enabled );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyAutomaticEvictionOfCollectionCaches(boolean enabled) {
|
||||
delegate.applyAutomaticEvictionOfCollectionCaches( enabled );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyJdbcBatchSize(int size) {
|
||||
delegate.applyJdbcBatchSize( size );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyJdbcBatchingForVersionedEntities(boolean enabled) {
|
||||
delegate.applyJdbcBatchingForVersionedEntities( enabled );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyScrollableResultsSupport(boolean enabled) {
|
||||
delegate.applyScrollableResultsSupport( enabled );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyResultSetsWrapping(boolean enabled) {
|
||||
delegate.applyResultSetsWrapping( enabled );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyGetGeneratedKeysSupport(boolean enabled) {
|
||||
delegate.applyGetGeneratedKeysSupport( enabled );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyJdbcFetchSize(int size) {
|
||||
delegate.applyJdbcFetchSize( size );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyConnectionReleaseMode(ConnectionReleaseMode connectionReleaseMode) {
|
||||
delegate.applyConnectionReleaseMode( connectionReleaseMode );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applySqlComments(boolean enabled) {
|
||||
delegate.applySqlComments( enabled );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applySqlFunction(
|
||||
String registrationName,
|
||||
SQLFunction sqlFunction) {
|
||||
delegate.applySqlFunction( registrationName, sqlFunction );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends SessionFactoryBuilder> T unwrap(Class<T> type) {
|
||||
return (T) this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,330 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2015, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.boot.spi;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.ConnectionReleaseMode;
|
||||
import org.hibernate.CustomEntityDirtinessStrategy;
|
||||
import org.hibernate.EntityMode;
|
||||
import org.hibernate.EntityNameResolver;
|
||||
import org.hibernate.Interceptor;
|
||||
import org.hibernate.MultiTenancyStrategy;
|
||||
import org.hibernate.NullPrecedence;
|
||||
import org.hibernate.SessionFactoryObserver;
|
||||
import org.hibernate.boot.SchemaAutoTooling;
|
||||
import org.hibernate.boot.TempTableDdlTransactionHandling;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.cache.spi.QueryCacheFactory;
|
||||
import org.hibernate.cfg.BaselineSessionEventsListenerBuilder;
|
||||
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
|
||||
import org.hibernate.dialect.function.SQLFunction;
|
||||
import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy;
|
||||
import org.hibernate.loader.BatchFetchStyle;
|
||||
import org.hibernate.proxy.EntityNotFoundDelegate;
|
||||
import org.hibernate.resource.jdbc.spi.StatementInspector;
|
||||
import org.hibernate.tuple.entity.EntityTuplizerFactory;
|
||||
|
||||
/**
|
||||
* Convenience base class for custom implementors of SessionFactoryOptions, using delegation
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public abstract class AbstractDelegatingSessionFactoryOptions implements SessionFactoryOptions {
|
||||
private final SessionFactoryOptions delegate;
|
||||
|
||||
public AbstractDelegatingSessionFactoryOptions(SessionFactoryOptions delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StandardServiceRegistry getServiceRegistry() {
|
||||
return delegate.getServiceRegistry();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getBeanManagerReference() {
|
||||
return delegate.getBeanManagerReference();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValidatorFactoryReference() {
|
||||
return delegate.getValidatorFactoryReference();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSessionFactoryName() {
|
||||
return delegate.getSessionFactoryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSessionFactoryNameAlsoJndiName() {
|
||||
return delegate.isSessionFactoryNameAlsoJndiName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFlushBeforeCompletionEnabled() {
|
||||
return delegate.isFlushBeforeCompletionEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoCloseSessionEnabled() {
|
||||
return delegate.isAutoCloseSessionEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStatisticsEnabled() {
|
||||
return delegate.isStatisticsEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interceptor getInterceptor() {
|
||||
return delegate.getInterceptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatementInspector getStatementInspector() {
|
||||
return delegate.getStatementInspector();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryObserver[] getSessionFactoryObservers() {
|
||||
return delegate.getSessionFactoryObservers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaselineSessionEventsListenerBuilder getBaselineSessionEventsListenerBuilder() {
|
||||
return delegate.getBaselineSessionEventsListenerBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIdentifierRollbackEnabled() {
|
||||
return delegate.isIdentifierRollbackEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityMode getDefaultEntityMode() {
|
||||
return delegate.getDefaultEntityMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityTuplizerFactory getEntityTuplizerFactory() {
|
||||
return delegate.getEntityTuplizerFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCheckNullability() {
|
||||
return delegate.isCheckNullability();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitializeLazyStateOutsideTransactionsEnabled() {
|
||||
return delegate.isInitializeLazyStateOutsideTransactionsEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiTableBulkIdStrategy getMultiTableBulkIdStrategy() {
|
||||
return delegate.getMultiTableBulkIdStrategy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TempTableDdlTransactionHandling getTempTableDdlTransactionHandling() {
|
||||
return delegate.getTempTableDdlTransactionHandling();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BatchFetchStyle getBatchFetchStyle() {
|
||||
return delegate.getBatchFetchStyle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultBatchFetchSize() {
|
||||
return delegate.getDefaultBatchFetchSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getMaximumFetchDepth() {
|
||||
return delegate.getMaximumFetchDepth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NullPrecedence getDefaultNullPrecedence() {
|
||||
return delegate.getDefaultNullPrecedence();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOrderUpdatesEnabled() {
|
||||
return delegate.isOrderUpdatesEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOrderInsertsEnabled() {
|
||||
return delegate.isOrderInsertsEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiTenancyStrategy getMultiTenancyStrategy() {
|
||||
return delegate.getMultiTenancyStrategy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CurrentTenantIdentifierResolver getCurrentTenantIdentifierResolver() {
|
||||
return delegate.getCurrentTenantIdentifierResolver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJtaTrackByThread() {
|
||||
return delegate.isJtaTrackByThread();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map getQuerySubstitutions() {
|
||||
return delegate.getQuerySubstitutions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStrictJpaQueryLanguageCompliance() {
|
||||
return delegate.isStrictJpaQueryLanguageCompliance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNamedQueryStartupCheckingEnabled() {
|
||||
return delegate.isNamedQueryStartupCheckingEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecondLevelCacheEnabled() {
|
||||
return delegate.isSecondLevelCacheEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isQueryCacheEnabled() {
|
||||
return delegate.isQueryCacheEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryCacheFactory getQueryCacheFactory() {
|
||||
return delegate.getQueryCacheFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCacheRegionPrefix() {
|
||||
return delegate.getCacheRegionPrefix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMinimalPutsEnabled() {
|
||||
return delegate.isMinimalPutsEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStructuredCacheEntriesEnabled() {
|
||||
return delegate.isStructuredCacheEntriesEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirectReferenceCacheEntriesEnabled() {
|
||||
return delegate.isDirectReferenceCacheEntriesEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoEvictCollectionCache() {
|
||||
return delegate.isAutoEvictCollectionCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchemaAutoTooling getSchemaAutoTooling() {
|
||||
return delegate.getSchemaAutoTooling();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getJdbcBatchSize() {
|
||||
return delegate.getJdbcBatchSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJdbcBatchVersionedData() {
|
||||
return delegate.isJdbcBatchVersionedData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isScrollableResultSetsEnabled() {
|
||||
return delegate.isScrollableResultSetsEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWrapResultSetsEnabled() {
|
||||
return delegate.isWrapResultSetsEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGetGeneratedKeysEnabled() {
|
||||
return delegate.isGetGeneratedKeysEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getJdbcFetchSize() {
|
||||
return delegate.getJdbcFetchSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConnectionReleaseMode getConnectionReleaseMode() {
|
||||
return delegate.getConnectionReleaseMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommentsEnabled() {
|
||||
return delegate.isCommentsEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomEntityDirtinessStrategy getCustomEntityDirtinessStrategy() {
|
||||
return delegate.getCustomEntityDirtinessStrategy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNameResolver[] getEntityNameResolvers() {
|
||||
return delegate.getEntityNameResolvers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNotFoundDelegate getEntityNotFoundDelegate() {
|
||||
return delegate.getEntityNotFoundDelegate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, SQLFunction> getCustomSqlFunctionMap() {
|
||||
return delegate.getCustomSqlFunctionMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCheckNullability(boolean enabled) {
|
||||
delegate.setCheckNullability( enabled );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPreferUserTransaction() {
|
||||
return delegate.isPreferUserTransaction();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue