1
1
/*
2
- * Copyright 2009-2023 the original author or authors.
2
+ * Copyright 2009-2024 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -87,6 +87,10 @@ public Configuration getConfiguration() {
87
87
return configuration ;
88
88
}
89
89
90
+ protected SqlSession createSqlSession (Configuration configuration , Executor executor , boolean autoCommit ) {
91
+ return new DefaultSqlSession (configuration , executor , autoCommit );
92
+ }
93
+
90
94
private SqlSession openSessionFromDataSource (ExecutorType execType , TransactionIsolationLevel level ,
91
95
boolean autoCommit ) {
92
96
Transaction tx = null ;
@@ -95,7 +99,7 @@ private SqlSession openSessionFromDataSource(ExecutorType execType, TransactionI
95
99
final TransactionFactory transactionFactory = getTransactionFactoryFromEnvironment (environment );
96
100
tx = transactionFactory .newTransaction (environment .getDataSource (), level , autoCommit );
97
101
final Executor executor = configuration .newExecutor (tx , execType );
98
- return new DefaultSqlSession (configuration , executor , autoCommit );
102
+ return createSqlSession (configuration , executor , autoCommit );
99
103
} catch (Exception e ) {
100
104
closeTransaction (tx ); // may have fetched a connection so lets call close()
101
105
throw ExceptionFactory .wrapException ("Error opening session. Cause: " + e , e );
@@ -118,7 +122,7 @@ private SqlSession openSessionFromConnection(ExecutorType execType, Connection c
118
122
final TransactionFactory transactionFactory = getTransactionFactoryFromEnvironment (environment );
119
123
final Transaction tx = transactionFactory .newTransaction (connection );
120
124
final Executor executor = configuration .newExecutor (tx , execType );
121
- return new DefaultSqlSession (configuration , executor , autoCommit );
125
+ return createSqlSession (configuration , executor , autoCommit );
122
126
} catch (Exception e ) {
123
127
throw ExceptionFactory .wrapException ("Error opening session. Cause: " + e , e );
124
128
} finally {
0 commit comments