Skip to content

Can not fetch an object from Cursor when a RowBounds is used #660

@kazuki43zoo

Description

@kazuki43zoo

MyBatis version

3.4.0

Database vendor and version

Any

Test case or example project

See CursorSimpleTest#testCursorWithRowBound.

Steps to reproduce

I added foreach processing for Cursor in test case as follow:

Cursor<User> usersCursor = sqlSession.selectCursor("getAllUsers", null, new RowBounds(1, 2));
for(User user: usersCursor) { // Add
    System.out.println(user);
}

Expected result

I expected print as follow:

User{id=2, name='User2'}
User{id=3, name='User3'}

Actual result

This code occurred the CursorException.

User{id=2, name='User2'}

org.apache.ibatis.cursor.CursorException: Cursor is closed

    at org.apache.ibatis.cursor.defaults.DefaultCursor$CursorIterator.next(DefaultCursor.java:207)
    at org.apache.ibatis.submitted.cursor_simple.CursorSimpleTest.testCursorWithRowBound2(CursorSimpleTest.java:169)
...

Related links

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions