diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/ForwardingSessionBuilder.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/AbstractDelegatingSessionBuilder.java similarity index 65% rename from hibernate-core/src/main/java/org/hibernate/engine/spi/ForwardingSessionBuilder.java rename to hibernate-core/src/main/java/org/hibernate/engine/spi/AbstractDelegatingSessionBuilder.java index 0c2c98ad54..2fc1a32c6e 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/ForwardingSessionBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/AbstractDelegatingSessionBuilder.java @@ -21,11 +21,11 @@ import org.hibernate.resource.jdbc.spi.StatementInspector; * * @author Gunnar Morling */ -public class ForwardingSessionBuilder implements SessionBuilder { +public abstract class AbstractDelegatingSessionBuilder implements SessionBuilder { private final SessionBuilder delegate; - public ForwardingSessionBuilder(SessionBuilder delegate) { + public AbstractDelegatingSessionBuilder(SessionBuilder delegate) { this.delegate = delegate; } @@ -36,57 +36,67 @@ public class ForwardingSessionBuilder implements SessionBuilder { @Override public SessionBuilder interceptor(Interceptor interceptor) { - return delegate.interceptor(interceptor); + delegate.interceptor( interceptor ); + return this; } @Override public SessionBuilder noInterceptor() { - return delegate.noInterceptor(); + delegate.noInterceptor(); + return this; } @Override public SessionBuilder statementInspector(StatementInspector statementInspector) { - return delegate.statementInspector( statementInspector ); + delegate.statementInspector( statementInspector ); + return this; } @Override public SessionBuilder connection(Connection connection) { - return delegate.connection(connection); + delegate.connection( connection ); + return this; } @Override - public SessionBuilder connectionReleaseMode( - ConnectionReleaseMode connectionReleaseMode) { - return delegate.connectionReleaseMode(connectionReleaseMode); + public SessionBuilder connectionReleaseMode(ConnectionReleaseMode connectionReleaseMode) { + delegate.connectionReleaseMode( connectionReleaseMode ); + return this; } @Override public SessionBuilder autoJoinTransactions(boolean autoJoinTransactions) { - return delegate.autoJoinTransactions(autoJoinTransactions); + delegate.autoJoinTransactions( autoJoinTransactions ); + return this; } @Override public SessionBuilder autoClose(boolean autoClose) { - return delegate.autoClose(autoClose); + delegate.autoClose( autoClose ); + return this; } @Override public SessionBuilder flushBeforeCompletion(boolean flushBeforeCompletion) { - return delegate.flushBeforeCompletion(flushBeforeCompletion); + delegate.flushBeforeCompletion( flushBeforeCompletion ); + return this; } @Override public SessionBuilder tenantIdentifier(String tenantIdentifier) { - return delegate.tenantIdentifier(tenantIdentifier); + delegate.tenantIdentifier( tenantIdentifier ); + return this; } @Override public SessionBuilder eventListeners(SessionEventListener... listeners) { - return delegate.eventListeners(listeners); + delegate.eventListeners( listeners ); + return this; } @Override public SessionBuilder clearEventListeners() { - return delegate.clearEventListeners(); + delegate.clearEventListeners(); + return this; } } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/ForwardingSessionBuilderImplementor.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/AbstractDelegatingSessionBuilderImplementor.java similarity index 69% rename from hibernate-core/src/main/java/org/hibernate/engine/spi/ForwardingSessionBuilderImplementor.java rename to hibernate-core/src/main/java/org/hibernate/engine/spi/AbstractDelegatingSessionBuilderImplementor.java index ff7f3a9cb0..4b2fba9960 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/ForwardingSessionBuilderImplementor.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/AbstractDelegatingSessionBuilderImplementor.java @@ -14,17 +14,21 @@ import org.hibernate.SessionBuilder; * * @author Gunnar Morling */ -public class ForwardingSessionBuilderImplementor extends ForwardingSessionBuilder implements SessionBuilderImplementor { +@SuppressWarnings("unused") +public abstract class AbstractDelegatingSessionBuilderImplementor + extends AbstractDelegatingSessionBuilder + implements SessionBuilderImplementor { private final SessionBuilderImplementor delegate; - public ForwardingSessionBuilderImplementor(SessionBuilderImplementor delegate) { + public AbstractDelegatingSessionBuilderImplementor(SessionBuilderImplementor delegate) { super( delegate ); this.delegate = delegate; } @Override public SessionBuilder owner(SessionOwner sessionOwner) { - return delegate.owner(sessionOwner); + delegate.owner( sessionOwner ); + return this; } } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/ForwardingSharedSessionBuilder.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/AbstractDelegatingSharedSessionBuilder.java similarity index 59% rename from hibernate-core/src/main/java/org/hibernate/engine/spi/ForwardingSharedSessionBuilder.java rename to hibernate-core/src/main/java/org/hibernate/engine/spi/AbstractDelegatingSharedSessionBuilder.java index a97eebbde0..94d7a04ef9 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/ForwardingSharedSessionBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/AbstractDelegatingSharedSessionBuilder.java @@ -22,11 +22,12 @@ import org.hibernate.resource.jdbc.spi.StatementInspector; * * @author Gunnar Morling */ -public class ForwardingSharedSessionBuilder implements SharedSessionBuilder { +@SuppressWarnings("unused") +public abstract class AbstractDelegatingSharedSessionBuilder implements SharedSessionBuilder { private final SharedSessionBuilder delegate; - public ForwardingSharedSessionBuilder(SharedSessionBuilder delegate) { + public AbstractDelegatingSharedSessionBuilder(SharedSessionBuilder delegate) { this.delegate = delegate; } @@ -37,94 +38,109 @@ public class ForwardingSharedSessionBuilder implements SharedSessionBuilder { @Override public SharedSessionBuilder interceptor() { - return delegate.interceptor(); + delegate.interceptor(); + return this; } @Override public SharedSessionBuilder connection() { - return delegate.connection(); + delegate.connection(); + return this; } @Override public SharedSessionBuilder connectionReleaseMode() { - return delegate.connectionReleaseMode(); + delegate.connectionReleaseMode(); + return this; } @Override public SharedSessionBuilder autoJoinTransactions() { - return delegate.autoJoinTransactions(); + delegate.autoJoinTransactions(); + return this; } @Override public SharedSessionBuilder autoClose() { - return delegate.autoClose(); + delegate.autoClose(); + return this; } @Override public SharedSessionBuilder flushBeforeCompletion() { - return delegate.flushBeforeCompletion(); + delegate.flushBeforeCompletion(); + return this; } @Override public SharedSessionBuilder transactionContext() { - return delegate.transactionContext(); + delegate.transactionContext(); + return this; } @Override public SharedSessionBuilder interceptor(Interceptor interceptor) { - return delegate.interceptor(interceptor); + delegate.interceptor( interceptor ); + return this; } @Override public SharedSessionBuilder noInterceptor() { - return delegate.noInterceptor(); + delegate.noInterceptor(); + return this; } @Override public SessionBuilder statementInspector(StatementInspector statementInspector) { - return delegate.statementInspector( statementInspector ); + delegate.statementInspector( statementInspector ); + return this; } @Override public SharedSessionBuilder connection(Connection connection) { - return delegate.connection(connection); + delegate.connection( connection ); + return this; } @Override - public SharedSessionBuilder connectionReleaseMode( - ConnectionReleaseMode connectionReleaseMode) { - return delegate.connectionReleaseMode(connectionReleaseMode); + public SharedSessionBuilder connectionReleaseMode(ConnectionReleaseMode connectionReleaseMode) { + delegate.connectionReleaseMode( connectionReleaseMode ); + return this; } @Override - public SharedSessionBuilder autoJoinTransactions( - boolean autoJoinTransactions) { - return delegate.autoJoinTransactions(autoJoinTransactions); + public SharedSessionBuilder autoJoinTransactions(boolean autoJoinTransactions) { + delegate.autoJoinTransactions( autoJoinTransactions ); + return this; } @Override public SharedSessionBuilder autoClose(boolean autoClose) { - return delegate.autoClose(autoClose); + delegate.autoClose( autoClose ); + return this; } @Override - public SharedSessionBuilder flushBeforeCompletion( - boolean flushBeforeCompletion) { - return delegate.flushBeforeCompletion(flushBeforeCompletion); + public SharedSessionBuilder flushBeforeCompletion(boolean flushBeforeCompletion) { + delegate.flushBeforeCompletion( flushBeforeCompletion ); + return this; } @Override public SessionBuilder tenantIdentifier(String tenantIdentifier) { - return delegate.tenantIdentifier(tenantIdentifier); + delegate.tenantIdentifier( tenantIdentifier ); + return this; } @Override public SessionBuilder eventListeners(SessionEventListener... listeners) { - return delegate.eventListeners(listeners); + delegate.eventListeners( listeners ); + return this; } @Override public SessionBuilder clearEventListeners() { - return delegate.clearEventListeners(); + delegate.clearEventListeners(); + return this; } }