[#821] Optimise ResultQuery.fetchAny() executing fetchLazy() internally, and only fetching one record from the cursor

This commit is contained in:
Lukas Eder 2011-08-29 20:38:39 +00:00
parent c9e458216c
commit 2585672f88

View File

@ -214,14 +214,14 @@ abstract class AbstractResultQuery<R extends Record> extends AbstractQuery imple
@Override
public final R fetchAny() throws SQLException {
// TODO: restrict ROWNUM = 1
Result<R> r = fetch();
Cursor<R> c = fetchLazy();
if (r.size() > 0) {
return r.get(0);
try {
return c.fetchOne();
}
finally {
c.close();
}
return null;
}
@Override