@Test(expected = IllegalStateException.class) public void testHasNextThrow() throws Exception { ConnectionSource cs = createMock(ConnectionSource.class); cs.releaseConnection(null); CompiledStatement stmt = createMock(CompiledStatement.class); DatabaseResults results = createMock(DatabaseResults.class); expect(stmt.runQuery(null)).andReturn(results); expect(results.first()).andThrow(new SQLException("some database problem")); stmt.close(); replay(stmt, results, cs); SelectIterator<Foo, Integer> iterator = new SelectIterator<Foo, Integer>(Foo.class, null, null, cs, null, stmt, "statement", null); try { iterator.hasNext(); } finally { iterator.close(); } }
public boolean hasNextThrow() throws SQLException { if (closed) { return false; } if (alreadyMoved) { return true; } boolean result; if (first) { first = false; result = results.first(); } else { result = results.next(); } if (!result) { IOUtils.closeThrowSqlException(this, "iterator"); } alreadyMoved = true; return result; }
SelectIterator implements CloseableIterator<T> { public boolean hasNextThrow() throws SQLException { if (closed) { return false; } if (alreadyMoved) { return true; } boolean result; if (first) { first = false; result = results.first(); } else { result = results.next(); } if (!result) { IOUtils.closeThrowSqlException(this, "iterator"); } alreadyMoved = true; return result; } }
SelectIterator implements CloseableIterator<T> { public boolean hasNextThrow() throws SQLException { if (closed) { return false; } if (alreadyMoved) { return true; } boolean result; if (first) { first = false; result = results.first(); } else { result = results.next(); } if (!result) { IOUtils.closeThrowSqlException(this, "iterator"); } alreadyMoved = true; return result; } SelectIterator(Class<?> dataClass, Dao<T, ID> classDao, GenericRowMapper<T> rowMapper,
			ConnectionSource connectionSource, DatabaseConnection connection, CompiledStatement compiledStmt,
			String statement, ObjectCache objectCache); }
SelectIterator implements CloseableIterator<T> { public boolean hasNextThrow() throws SQLException { if (closed) { return false; } if (alreadyMoved) { return true; } boolean result; if (first) { first = false; result = results.first(); } else { result = results.next(); } if (!result) { IOUtils.closeThrowSqlException(this, "iterator"); } alreadyMoved = true; return result; } SelectIterator(Class<?> dataClass, Dao<T, ID> classDao, GenericRowMapper<T> rowMapper,
			ConnectionSource connectionSource, DatabaseConnection connection, CompiledStatement compiledStmt,
			String statement, ObjectCache objectCache); boolean hasNextThrow(); @Override boolean hasNext(); @Override T first(); @Override T previous(); @Override T current(); @Override T nextThrow(); @Override T next(); @Override T moveRelative(int offset); void removeThrow(); @Override void remove(); @Override void close(); @Override void closeQuietly(); @Override DatabaseResults getRawResults(); @Override void moveToNext(); }
SelectIterator implements CloseableIterator<T> { public boolean hasNextThrow() throws SQLException { if (closed) { return false; } if (alreadyMoved) { return true; } boolean result; if (first) { first = false; result = results.first(); } else { result = results.next(); } if (!result) { IOUtils.closeThrowSqlException(this, "iterator"); } alreadyMoved = true; return result; } SelectIterator(Class<?> dataClass, Dao<T, ID> classDao, GenericRowMapper<T> rowMapper,
			ConnectionSource connectionSource, DatabaseConnection connection, CompiledStatement compiledStmt,
			String statement, ObjectCache objectCache); boolean hasNextThrow(); @Override boolean hasNext(); @Override T first(); @Override T previous(); @Override T current(); @Override T nextThrow(); @Override T next(); @Override T moveRelative(int offset); void removeThrow(); @Override void remove(); @Override void close(); @Override void closeQuietly(); @Override DatabaseResults getRawResults(); @Override void moveToNext();  }