Skip to content

Commit

Permalink
mybatis#437: Polishing some logics and comments
Browse files Browse the repository at this point in the history
* modify to use Cursor.class.isAssignableFrom(Class<?>)
* modfiy to use ExceptionFactory.wrapException(String,Exception)
* modify copyright year
  • Loading branch information
kazuki43zoo committed Jul 12, 2015
1 parent 33c1e9f commit e04b8fd
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/main/java/org/apache/ibatis/binding/MapperMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* @author Clinton Begin
* @author Eduardo Macarron
* @author Lasse Voss
* @author Kazuki Shimizu
*/
public class MapperMethod {

Expand Down Expand Up @@ -245,7 +246,7 @@ public MethodSignature(Configuration configuration, Method method) {
this.returnType = method.getReturnType();
this.returnsVoid = void.class.equals(this.returnType);
this.returnsMany = (configuration.getObjectFactory().isCollection(this.returnType) || this.returnType.isArray());
this.returnsCursor = Cursor.class.equals(this.returnType);
this.returnsCursor = Cursor.class.isAssignableFrom(this.returnType);
this.mapKey = getMapKey(method);
this.returnsMap = (this.mapKey != null);
this.hasNamedParameters = hasNamedParams(method);
Expand Down
17 changes: 14 additions & 3 deletions src/main/java/org/apache/ibatis/cursor/defaults/DefaultCursor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,6 +33,7 @@

/**
* @author Guillaume Darmont / [email protected]
* @author Kazuki Shimizu
*/
public class DefaultCursor<T> implements Cursor<T> {

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

--
-- Copyright 2009-2012 The MyBatis Team
-- Copyright 2009-2015 The MyBatis Team
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2009-2012 The MyBatis Team
Copyright 2009-2015 The MyBatis Team
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright 2009-2012 The MyBatis Team
Copyright 2009-2015 The MyBatis Team
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--
-- Copyright 2009-2012 The MyBatis Team
-- Copyright 2009-2015 The MyBatis Team
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2009-2012 The MyBatis Team
Copyright 2009-2015 The MyBatis Team
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright 2009-2012 The MyBatis Team
Copyright 2009-2015 The MyBatis Team
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down

0 comments on commit e04b8fd

Please sign in to comment.