forked from mybatis/mybatis-3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mybatis#437: Polishing some logics and comments
* modify to use Cursor.class.isAssignableFrom(Class<?>) * modfiy to use ExceptionFactory.wrapException(String,Exception) * modify copyright year
- Loading branch information
1 parent
33c1e9f
commit e04b8fd
Showing
8 changed files
with
22 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,8 @@ | |
package org.apache.ibatis.cursor.defaults; | ||
|
||
import org.apache.ibatis.cursor.Cursor; | ||
import org.apache.ibatis.exceptions.ExceptionFactory; | ||
import org.apache.ibatis.executor.ErrorContext; | ||
import org.apache.ibatis.executor.resultset.DefaultResultSetHandler; | ||
import org.apache.ibatis.executor.resultset.ResultSetWrapper; | ||
import org.apache.ibatis.mapping.ResultMap; | ||
|
@@ -31,6 +33,7 @@ | |
|
||
/** | ||
* @author Guillaume Darmont / [email protected] | ||
* @author Kazuki Shimizu | ||
*/ | ||
public class DefaultCursor<T> implements Cursor<T> { | ||
|
||
|
@@ -111,7 +114,7 @@ protected T fetchNextObjectFromDatabase() { | |
opened = true; | ||
resultSetHandler.handleRowValues(rsw, resultMap, objectWrapperResultHandler, RowBounds.DEFAULT, null); | ||
} catch (SQLException e) { | ||
throw new RuntimeException(e); | ||
ExceptionFactory.wrapException("Error fetching next object from database at the DefaultCursor.", e); | ||
} | ||
|
||
T next = objectWrapperResultHandler.result; | ||
|
@@ -160,7 +163,11 @@ public CursorIterator() { | |
@Override | ||
public boolean hasNext() { | ||
if (object == null) { | ||
object = fetchNextUsingRowBound(); | ||
try { | ||
object = fetchNextUsingRowBound(); | ||
} finally { | ||
ErrorContext.instance().reset(); | ||
} | ||
} | ||
return object != null; | ||
} | ||
|
@@ -171,7 +178,11 @@ public T next() { | |
T next = object; | ||
|
||
if (next == null) { | ||
next = fetchNextUsingRowBound(); | ||
try { | ||
next = fetchNextUsingRowBound(); | ||
} finally { | ||
ErrorContext.instance().reset(); | ||
} | ||
} | ||
|
||
if (next != null) { | ||
|
2 changes: 1 addition & 1 deletion
2
src/test/java/org/apache/ibatis/submitted/cursor_nested/CreateDB.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/test/java/org/apache/ibatis/submitted/cursor_nested/Mapper.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/test/java/org/apache/ibatis/submitted/cursor_nested/mybatis-config.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/test/java/org/apache/ibatis/submitted/cursor_simple/CreateDB.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/test/java/org/apache/ibatis/submitted/cursor_simple/Mapper.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/test/java/org/apache/ibatis/submitted/cursor_simple/mybatis-config.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters