@Override public T next() { if (scrollableCursor == null) { throw new NoSuchElementException("No ScrollableCursor"); } return (T) scrollableCursor.next(); }
Query query = em.createQuery... query.setHint(QueryHints.CURSOR, true) .setHint(QueryHints.SCROLLABLE_CURSOR, true) ScrollableCursor scrl = (ScrollableCursor)q.getSingleResult(); Object o = null; while ((o = scrl.next()) != null) { ... }
/** * PUBLIC: * Return the next object from the collection, if beyond the read limit read from the cursor. * @return next object in stream */ public Object nextElement() throws DatabaseException, QueryException { return next(); }
/** * PUBLIC: * Return the next object from the collection, if beyond the read limit read from the cursor. * @return next object in stream */ public Object nextElement() throws DatabaseException, QueryException { return next(); }
/** * PUBLIC: * Return the next object from the collection, if beyond the read limit read from the cursor. * @return next object in stream */ public Object nextElement() throws DatabaseException, QueryException { return next(); }
@Override public T next() { if (scrollableCursor == null) { throw new NoSuchElementException("No ScrollableCursor"); } return (T) scrollableCursor.next(); }
/** * PUBLIC: * This method differs slightly from conventional read() operation on a Java stream. This * method returns the next number of objects in the collection in a vector. * * Return the next specified number of objects from the collection, if beyond the read limit read from the cursor * @param number - number of objects to be returned * @return - vector containing next number of objects * @throws DatabaseException if read pass end of stream */ public List<Object> next(int number) throws DatabaseException { List<Object> result = new ArrayList(number); for (int index = 0; index < number; index++) { result.add(next()); } return result; }
/** * PUBLIC: * This method differs slightly from conventional read() operation on a Java stream. This * method returns the next number of objects in the collection in a vector. * * Return the next specified number of objects from the collection, if beyond the read limit read from the cursor * @param number - number of objects to be returned * @return - vector containing next number of objects * @exception - throws exception if read pass end of stream */ public Vector next(int number) throws DatabaseException { Vector result = new Vector(number); for (int index = 0; index < number; index++) { result.addElement(next()); } return result; }
/** * PUBLIC: * This method differs slightly from conventional read() operation on a Java stream. This * method returns the next number of objects in the collection in a vector. * * Return the next specified number of objects from the collection, if beyond the read limit read from the cursor * @param number - number of objects to be returned * @return - vector containing next number of objects * @throws DatabaseException if read pass end of stream */ public List<Object> next(int number) throws DatabaseException { List<Object> result = new ArrayList(number); for (int index = 0; index < number; index++) { result.add(next()); } return result; }
ReadAllQuery query = new ReadAllQuery(); query.setReferenceClass(Employee.class); query.setSelectionCriteria(new ExpressionBuilder.get("id").greaterThan(100)); // Set the JDBC fetch size query.setFetchSize(50); // Configure the query to return results as a ScrollableCursor query.useScrollableCursor(); // Execute the query ScrollableCursor cursor = (ScrollableCursor) session.executeQuery(query); // Iterate over the results while (cursor.hasNext()) { System.out.println(cursor.next().toString()); } cursor.close();
/** * Retrieve next object from the scrollable cursor */ public Transporter scrollableCursorNextObject(Transporter remoteScrollableCursorOid) { Transporter transporter = new Transporter(); try { ScrollableCursor stream = (ScrollableCursor)getRemoteCursors().get(remoteScrollableCursorOid.getObject()); if (stream != null) { Object objectNext = null; // For bug 2797683 read beyond end of stream exception should not be thrown here: called first by RemoteScrollableCursor.hasNext(). if (stream.hasNext()) { objectNext = stream.next(); } if (objectNext == null) { // 2612538 - the default size of Map (32) is appropriate transporter.setObjectDescriptors(new IdentityHashMap()); } else { if (stream.getQuery().isReadAllQuery() && (!stream.getQuery().isReportQuery())) { transporter.setObjectDescriptors(replaceValueHoldersIn(objectNext)); } } transporter.setObject(objectNext); } } catch (RuntimeException exception) { transporter.setException(exception); } return transporter; }
/** * Retrieve next object from the scrollable cursor */ public Transporter scrollableCursorNextObject(Transporter remoteScrollableCursorOid) { Transporter transporter = new Transporter(); try { ScrollableCursor stream = (ScrollableCursor)getRemoteCursors().get(remoteScrollableCursorOid.getObject()); if (stream != null) { Object objectNext = null; // For bug 2797683 read beyond end of stream exception should not be thrown here: called first by RemoteScrollableCursor.hasNext(). if (stream.hasNext()) { objectNext = stream.next(); } if (objectNext == null) { // 2612538 - the default size of Map (32) is appropriate transporter.setObjectDescriptors(new IdentityHashMap()); } else { if (stream.getQuery().isReadAllQuery() && (!stream.getQuery().isReportQuery())) { transporter.setObjectDescriptors(replaceValueHoldersIn(objectNext)); } } transporter.setObject(objectNext); } } catch (RuntimeException exception) { transporter.setException(exception); } return transporter; }
/** * Retrieve next object from the scrollable cursor */ public Transporter scrollableCursorNextObject(Transporter remoteScrollableCursorOid) { Transporter transporter = new Transporter(); try { ScrollableCursor stream = (ScrollableCursor)getRemoteCursors().get(remoteScrollableCursorOid.getObject()); if (stream != null) { Object objectNext = null; // For bug 2797683 read beyond end of stream exception should not be thrown here: called first by RemoteScrollableCursor.hasNext(). if (stream.hasNext()) { objectNext = stream.next(); } if (objectNext == null) { // 2612538 - the default size of Map (32) is appropriate transporter.setObjectDescriptors(new IdentityHashMap()); } else { if (stream.getQuery().isReadAllQuery() && (!stream.getQuery().isReportQuery())) { transporter.setObjectDescriptors(replaceValueHoldersIn(objectNext)); } } transporter.setObject(objectNext); } } catch (RuntimeException exception) { transporter.setException(exception); } return transporter; }