99import org .hibernate .Interceptor ;
1010import org .hibernate .SessionEventListener ;
1111import org .hibernate .engine .creation .spi .SessionBuilderImplementor ;
12+ import org .hibernate .engine .spi .SessionFactoryImplementor ;
13+ import org .hibernate .engine .spi .SessionImplementor ;
1214import org .hibernate .internal .CoreLogging ;
13- import org .hibernate .internal .SessionFactoryImpl ;
14- import org .hibernate .internal .SessionImpl ;
1515import org .hibernate .resource .jdbc .spi .PhysicalConnectionHandlingMode ;
1616import org .hibernate .resource .jdbc .spi .StatementInspector ;
1717import org .jboss .logging .Logger ;
2828 *
2929 * @author Steve Ebersole
3030 */
31- public class SessionBuilderImpl
31+ public abstract class SessionBuilderImpl
3232 extends AbstractCommonBuilder <SessionBuilderImplementor >
3333 implements SessionBuilderImplementor , SessionCreationOptions {
34- private static final Logger log = CoreLogging .logger ( SessionBuilderImpl .class );
34+
35+ private static final Logger LOG = CoreLogging .logger ( SessionBuilderImpl .class );
3536
3637 private boolean autoJoinTransactions = true ;
37- private FlushMode flushMode ;
3838 private boolean autoClose ;
3939 private boolean autoClear ;
4040 private boolean identifierRollback ;
4141 private TimeZone jdbcTimeZone ;
42+ private FlushMode flushMode ;
43+
4244 private final int defaultBatchFetchSize ;
4345 private final boolean subselectFetchEnabled ;
4446
@@ -47,21 +49,15 @@ public class SessionBuilderImpl
4749 // Only initialize of the builder is overriding the default.
4850 private List <SessionEventListener > listeners ;
4951
50- public SessionBuilderImpl (SessionFactoryImpl sessionFactory ) {
52+ public SessionBuilderImpl (SessionFactoryImplementor sessionFactory ) {
5153 super ( sessionFactory );
52-
53- // set up default builder values...
54+ // set up default builder values
5455 final var options = sessionFactory .getSessionFactoryOptions ();
55- statementInspector = options .getStatementInspector ();
56- connectionHandlingMode = options .getPhysicalConnectionHandlingMode ();
5756 autoClose = options .isAutoCloseSessionEnabled ();
58- defaultBatchFetchSize = options .getDefaultBatchFetchSize ();
59- subselectFetchEnabled = options .isSubselectFetchEnabled ();
6057 identifierRollback = options .isIdentifierRollbackEnabled ();
61- cacheMode = options .getInitialSessionCacheMode ();
62-
63- tenantIdentifier = sessionFactory .resolveTenantIdentifier ();
6458 jdbcTimeZone = options .getJdbcTimeZone ();
59+ defaultBatchFetchSize = options .getDefaultBatchFetchSize ();
60+ subselectFetchEnabled = options .isSubselectFetchEnabled ();
6561 }
6662
6763 @ Override
@@ -110,8 +106,7 @@ public Connection getConnection() {
110106
111107 @ Override
112108 public Interceptor getInterceptor () {
113- return SessionFactoryImpl .configuredInterceptor ( interceptor , explicitNoInterceptor ,
114- sessionFactory .getSessionFactoryOptions () );
109+ return configuredInterceptor ();
115110 }
116111
117112 @ Override
@@ -157,19 +152,21 @@ public TimeZone getJdbcTimeZone() {
157152 }
158153
159154 @ Override
160- public List <SessionEventListener > getCustomSessionEventListener () {
155+ public List <SessionEventListener > getCustomSessionEventListeners () {
161156 return listeners ;
162157 }
163158
164159 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
165160 // SessionBuilder
166161
167162 @ Override
168- public SessionImpl openSession () {
169- log .tracef ( "Opening Hibernate Session. tenant=%s" , tenantIdentifier );
170- return new SessionImpl ( sessionFactory , this );
163+ public SessionImplementor openSession () {
164+ LOG .tracef ( "Opening Hibernate Session [ tenant=%s] " , tenantIdentifier );
165+ return createSession ( );
171166 }
172167
168+ protected abstract SessionImplementor createSession ();
169+
173170 @ Override
174171 @ Deprecated
175172 public SessionBuilderImplementor statementInspector (StatementInspector statementInspector ) {
@@ -250,6 +247,4 @@ public SessionBuilderImplementor jdbcTimeZone(TimeZone timeZone) {
250247 jdbcTimeZone = timeZone ;
251248 return this ;
252249 }
253-
254-
255250}
0 commit comments