-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
AbstractDelegatingSessionBuilder.java
147 lines (123 loc) · 3.49 KB
/
AbstractDelegatingSessionBuilder.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
* 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.engine.spi;
import java.sql.Connection;
import java.util.TimeZone;
import org.hibernate.ConnectionReleaseMode;
import org.hibernate.FlushMode;
import org.hibernate.Interceptor;
import org.hibernate.Session;
import org.hibernate.SessionBuilder;
import org.hibernate.SessionEventListener;
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
import org.hibernate.resource.jdbc.spi.StatementInspector;
/**
* Base class for {@link SessionBuilder} implementations that wish to implement only parts of that contract themselves
* while forwarding other method invocations to a delegate instance.
*
* @author Gunnar Morling
* @author Guillaume Smet
*/
public abstract class AbstractDelegatingSessionBuilder<T extends SessionBuilder> implements SessionBuilder<T> {
private final SessionBuilder delegate;
public AbstractDelegatingSessionBuilder(SessionBuilder delegate) {
this.delegate = delegate;
}
@SuppressWarnings("unchecked")
protected T getThis() {
return (T) this;
}
protected SessionBuilder getDelegate() {
return delegate;
}
@Override
public Session openSession() {
return delegate.openSession();
}
@Override
public T interceptor(Interceptor interceptor) {
delegate.interceptor( interceptor );
return getThis();
}
@Override
public T noInterceptor() {
delegate.noInterceptor();
return getThis();
}
@Override
public T statementInspector(StatementInspector statementInspector) {
delegate.statementInspector( statementInspector );
return getThis();
}
@Override
public T connection(Connection connection) {
delegate.connection( connection );
return getThis();
}
@SuppressWarnings("deprecation")
@Override
public T connectionReleaseMode(ConnectionReleaseMode connectionReleaseMode) {
delegate.connectionReleaseMode( connectionReleaseMode );
return getThis();
}
@Override
public T autoJoinTransactions(boolean autoJoinTransactions) {
delegate.autoJoinTransactions( autoJoinTransactions );
return getThis();
}
@Override
public T autoClose(boolean autoClose) {
delegate.autoClose( autoClose );
return getThis();
}
@SuppressWarnings("deprecation")
@Override
public T flushBeforeCompletion(boolean flushBeforeCompletion) {
delegate.flushBeforeCompletion( flushBeforeCompletion );
return getThis();
}
@Override
public T tenantIdentifier(String tenantIdentifier) {
delegate.tenantIdentifier( tenantIdentifier );
return getThis();
}
@Override
public T eventListeners(SessionEventListener... listeners) {
delegate.eventListeners( listeners );
return getThis();
}
@Override
public T clearEventListeners() {
delegate.clearEventListeners();
return getThis();
}
@Override
public T jdbcTimeZone(TimeZone timeZone) {
delegate.jdbcTimeZone(timeZone);
return getThis();
}
@Override
public T setQueryParameterValidation(boolean enabled) {
delegate.setQueryParameterValidation( enabled );
return getThis();
}
@Override
public T connectionHandlingMode(PhysicalConnectionHandlingMode mode) {
delegate.connectionHandlingMode( mode );
return getThis();
}
@Override
public T autoClear(boolean autoClear) {
delegate.autoClear( autoClear );
return getThis();
}
@Override
public T flushMode(FlushMode flushMode) {
delegate.flushMode( flushMode );
return getThis();
}
}