jora
Class Cursor

java.lang.Object
  |
  +--jora.Cursor

public class Cursor
extends java.lang.Object

Cursor is used for successive access to records fetched by SELECT statement. As far as records can be retrived from several derived tables (polymorphic form of select), this class can issue several requests to database. Cursor also provides methods for updating/deleting current record.


Method Summary
 void delete()
          Delete current record pointed by cursor.
 java.lang.Object next()
          A cursor is initially positioned before its first row; the first call to next makes the first row the current row; the second call makes the second row the current row, etc.
 java.lang.Object[] toArray()
          Store all objects returned by SELECT query into array of Object.
 java.lang.Object[] toArray(int maxElements)
          Extracts no more than maxElements records from database and store them into array.
 java.util.List toArrayList()
          Store all objects returned by SELECT query into a list of Object.
 java.util.List toArrayList(int maxElements)
          Extracts no more than maxElements records from database and store them into array.
 void update()
          Update current record pointed by cursor.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

next

public java.lang.Object next()
A cursor is initially positioned before its first row; the first call to next makes the first row the current row; the second call makes the second row the current row, etc.

If an input stream from the previous row is open, it is implicitly closed. The ResultSet's warning chain is cleared when a new row is read.

Returns:
object constructed from fetched record or null if there are no more rows

update

public void update()
Update current record pointed by cursor. This method can be called only after next() method, which returns non-null object. This objects is used to update current record fields.

If you are going to update or delete selected records, you should add "for update" clause to select statement. So parameter of jora.Table.select() statement should contain "for update" clause: record.table.Select("where name='xyz' for update");

Attention! Not all database drivers support update operation with cursor. This method will not work with such database drivers.


delete

public void delete()
Delete current record pointed by cursor. This method can be called only after next() method, which returns non-null object.

If you are going to update or delete selected records, you should add "for update" clause to select statement. So parameter of jora.Table.select() statement should contain "for update" clause: record.table.Select("where name='xyz' for update");

Attention! Not all database drivers support delete operation with cursor. This method will not work with such database drivers.


toArray

public java.lang.Object[] toArray(int maxElements)
Extracts no more than maxElements records from database and store them into array. It is possible to extract rest records by successive next() or toArray() calls. Selected objects should have now components of InputStream, Blob or Clob type, because their data will be not available after fetching next record.
Parameters:
maxElements - limitation for result array size (and also for number of fetched records)
Returns:
Array with objects constructed from fetched records.

toArray

public java.lang.Object[] toArray()
Store all objects returned by SELECT query into array of Object. Selected objects should have now components of InputStream, Blob or Clob type, because their data will be not available after fetching next record.
Returns:
Array with objects constructed from fetched records.

toArrayList

public java.util.List toArrayList(int maxElements)
Extracts no more than maxElements records from database and store them into array. It is possible to extract rest records by successive next() or toArray() calls. Selected objects should have now components of InputStream, Blob or Clob type, because their data will be not available after fetching next record.
Parameters:
maxElements - limitation for result array size (and also for number of fetched records)
Returns:
List with objects constructed from fetched records.

toArrayList

public java.util.List toArrayList()
Store all objects returned by SELECT query into a list of Object. Selected objects should have now components of InputStream, Blob or Clob type, because their data will be not available after fetching next record.
Returns:
Array with objects constructed from fetched records.