Skip to content

Commit a52d1e1

Browse files
committed
Added a flushStatments after a query to fix issue http://code.google.com/p/mybatis/issues/detail?id=138
1 parent 466a646 commit a52d1e1

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/main/java/org/apache/ibatis/executor/BatchExecutor.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,17 @@ public int doUpdate(MappedStatement ms, Object parameterObject)
5353

5454
public List doQuery(MappedStatement ms, Object parameterObject, RowBounds rowBounds, ResultHandler resultHandler)
5555
throws SQLException {
56-
flushStatements();
57-
Configuration configuration = ms.getConfiguration();
58-
StatementHandler handler = configuration.newStatementHandler(this, ms, parameterObject, rowBounds, resultHandler);
59-
Connection connection = transaction.getConnection();
60-
Statement stmt = handler.prepare(connection);
61-
handler.parameterize(stmt);
62-
return handler.query(stmt, resultHandler);
56+
try {
57+
flushStatements();
58+
Configuration configuration = ms.getConfiguration();
59+
StatementHandler handler = configuration.newStatementHandler(this, ms, parameterObject, rowBounds, resultHandler);
60+
Connection connection = transaction.getConnection();
61+
Statement stmt = handler.prepare(connection);
62+
handler.parameterize(stmt);
63+
return handler.query(stmt, resultHandler);
64+
} finally {
65+
flushStatements();
66+
}
6367
}
6468

6569
public List<BatchResult> doFlushStatements() throws SQLException {

0 commit comments

Comments
 (0)