HHH-11944 Add AbstractDelegatingSessionFactoryBuilderImplementor

This is missing from the set of delegating classes available.
This commit is contained in:
Guillaume Smet 2017-08-28 15:32:45 +02:00
parent 8de187594d
commit de1642ba93
2 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,43 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.boot.spi;
/**
* Convenience base class for custom implementors of {@link SessionFactoryBuilderImplementor}, using delegation
*
* @author Guillaume Smet
* @param <T> The type of a specific sub-class; Allows sub-classes to narrow down the return-type of the contract methods
* to a specialization of {@link SessionFactoryBuilderImplementor}
*/
public abstract class AbstractDelegatingSessionFactoryBuilderImplementor<T extends SessionFactoryBuilderImplementor>
extends AbstractDelegatingSessionFactoryBuilder<T> implements SessionFactoryBuilderImplementor {
public AbstractDelegatingSessionFactoryBuilderImplementor(SessionFactoryBuilderImplementor delegate) {
super( delegate );
}
@Override
protected SessionFactoryBuilderImplementor getDelegate() {
return (SessionFactoryBuilderImplementor) super.getDelegate();
}
@SuppressWarnings("deprecation")
@Override
public void markAsJpaBootstrap() {
getDelegate().markAsJpaBootstrap();
}
@Override
public void disableJtaTransactionAccess() {
getDelegate().disableJtaTransactionAccess();
}
@Override
public SessionFactoryOptions buildSessionFactoryOptions() {
return getDelegate().buildSessionFactoryOptions();
}
}

View File

@ -0,0 +1,29 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.boot.spi.delegation;
import org.hibernate.boot.spi.AbstractDelegatingSessionFactoryBuilderImplementor;
import org.hibernate.boot.spi.SessionFactoryBuilderImplementor;
/**
* If this class does not compile anymore due to unimplemented methods, you should probably add the corresponding
* methods to the parent class.
*
* @author Guillaume Smet
*/
public class TestDelegatingSessionFactoryBuilderImplementor extends AbstractDelegatingSessionFactoryBuilderImplementor<TestDelegatingSessionFactoryBuilderImplementor> {
public TestDelegatingSessionFactoryBuilderImplementor(SessionFactoryBuilderImplementor delegate) {
super( delegate );
}
@Override
protected TestDelegatingSessionFactoryBuilderImplementor getThis() {
return this;
}
}