-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1494 from hutteman/cursor-close
Improve Cursor Closeable behavior
- Loading branch information
Showing
5 changed files
with
17 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright 2009-2023 the original author or authors. | ||
* Copyright 2009-2025 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
|
@@ -15,16 +15,14 @@ | |
*/ | ||
package org.apache.ibatis.cursor; | ||
|
||
import java.io.Closeable; | ||
|
||
/** | ||
* Cursor contract to handle fetching items lazily using an Iterator. Cursors are a perfect fit to handle millions of | ||
* items queries that would not normally fit in memory. If you use collections in resultMaps then cursor SQL queries | ||
* must be ordered (resultOrdered="true") using the id columns of the resultMap. | ||
* | ||
* @author Guillaume Darmont / [email protected] | ||
*/ | ||
public interface Cursor<T> extends Closeable, Iterable<T> { | ||
public interface Cursor<T> extends AutoCloseable, Iterable<T> { | ||
|
||
/** | ||
* @return true if the cursor has started to fetch items from database. | ||
|
@@ -42,4 +40,10 @@ public interface Cursor<T> extends Closeable, Iterable<T> { | |
* @return -1 if the first cursor item has not been retrieved. The index of the current item retrieved. | ||
*/ | ||
int getCurrentIndex(); | ||
|
||
/** | ||
* Closes the cursor. | ||
*/ | ||
@Override | ||
void close(); | ||
} |
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
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