File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed
src/main/java/org/apache/ibatis/session Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 1
1
package org .apache .ibatis .session ;
2
2
3
+ import org .apache .ibatis .executor .BatchResult ;
4
+
3
5
import java .sql .Connection ;
4
6
import java .util .List ;
5
7
import java .util .Map ;
@@ -48,6 +50,8 @@ public interface SqlSession {
48
50
49
51
void rollback (boolean force );
50
52
53
+ public List <BatchResult > flushStatements ();
54
+
51
55
void close ();
52
56
53
57
void clearCache ();
Original file line number Diff line number Diff line change 1
1
package org .apache .ibatis .session ;
2
2
3
+ import org .apache .ibatis .exceptions .ExceptionFactory ;
4
+ import org .apache .ibatis .executor .BatchResult ;
5
+ import org .apache .ibatis .executor .ErrorContext ;
3
6
import org .apache .ibatis .reflection .ExceptionUtil ;
4
7
5
8
import java .io .InputStream ;
@@ -235,6 +238,12 @@ public void rollback(boolean force) {
235
238
sqlSession .rollback (force );
236
239
}
237
240
241
+ public List <BatchResult > flushStatements () {
242
+ final SqlSession sqlSession = localSqlSession .get ();
243
+ if (sqlSession == null ) throw new SqlSessionException ("Error: Cannot rollback. No managed session is started." );
244
+ return sqlSession .flushStatements ();
245
+ }
246
+
238
247
public void close () {
239
248
final SqlSession sqlSession = localSqlSession .get ();
240
249
if (sqlSession == null ) throw new SqlSessionException ("Error: Cannot close. No managed session is started." );
Original file line number Diff line number Diff line change 2
2
3
3
import org .apache .ibatis .exceptions .ExceptionFactory ;
4
4
import org .apache .ibatis .exceptions .TooManyResultsException ;
5
+ import org .apache .ibatis .executor .BatchResult ;
5
6
import org .apache .ibatis .executor .Executor ;
6
7
import org .apache .ibatis .executor .ErrorContext ;
7
8
import org .apache .ibatis .executor .result .DefaultMapResultHandler ;
@@ -164,6 +165,16 @@ public void rollback(boolean force) {
164
165
}
165
166
}
166
167
168
+ public List <BatchResult > flushStatements () {
169
+ try {
170
+ return executor .flushStatements ();
171
+ } catch (Exception e ) {
172
+ throw ExceptionFactory .wrapException ("Error flushing statements. Cause: " + e , e );
173
+ } finally {
174
+ ErrorContext .instance ().reset ();
175
+ }
176
+ }
177
+
167
178
public void close () {
168
179
try {
169
180
executor .close (isCommitOrRollbackRequired (false ));
You can’t perform that action at this time.
0 commit comments