public void test() { // stored procedure call StoredProcedureCall spCall = new StoredProcedureCall(); spCall.setProcedureName("Read_All_Employees"); spCall.useNamedCursorOutputAsResultSet("RESULT_CURSOR"); // query DirectReadQuery query = new DirectReadQuery(); query.setCall(spCall); query.useScrollableCursor(); cursor = (ScrollableCursor) getSession().executeQuery(query); // If the driver returns a forward-only ResultSet initialized to afterLast there's nothing // ScrollableCursor can do with it. try { if ((cursor.getResultSet().isAfterLast()) && (cursor.getResultSet().getType() == java.sql.ResultSet.TYPE_FORWARD_ONLY)) { throwWarning( "The ResultSet returned from the query is TYPE_FORWARD_ONLY and initialized to afterLast."); } } catch (java.sql.SQLException sqle) { throwWarning("Unexpected SQLException thrown while checking the ResultSet."); } // iterate the cursor try { while (cursor.hasNext()) { cursor.next(); } } catch (org.eclipse.persistence.exceptions.DatabaseException dbe) { caughtException = dbe; } finally { if (cursor != null) { cursor.close(); } } }