|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.samskivert.jdbc.jora.Cursor<V>
public class Cursor<V>
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.
| Field Summary | |
|---|---|
protected Connection |
_conn
|
protected V |
_currObject
|
protected boolean |
_like
|
protected FieldMask |
_qbeMask
|
protected V |
_qbeObject
|
protected String |
_query
|
protected ResultSet |
_result
|
protected Statement |
_stmt
|
protected Table<V> |
_table
|
| Constructor Summary | |
|---|---|
protected |
Cursor(Table<V> table,
Connection conn,
String query)
|
protected |
Cursor(Table<V> table,
Connection conn,
V obj,
FieldMask mask,
boolean like)
|
| Method Summary | |
|---|---|
void |
close()
Close the Cursor, even if we haven't read all the possible objects. |
void |
delete()
Delete current record pointed by cursor. |
V |
get()
Returns the first element matched by this cursor or null if no elements were matched. |
V |
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. |
ArrayList<V> |
toArrayList()
Store all objects returned by SELECT query into a list of Object. |
ArrayList<V> |
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 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Table<V> _table
protected Connection _conn
protected ResultSet _result
protected String _query
protected Statement _stmt
protected V _currObject
protected V _qbeObject
protected FieldMask _qbeMask
protected boolean _like
| Constructor Detail |
|---|
protected Cursor(Table<V> table,
Connection conn,
String query)
protected Cursor(Table<V> table,
Connection conn,
V obj,
FieldMask mask,
boolean like)
| Method Detail |
|---|
public V next()
throws SQLException
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.
SQLException
public V get()
throws SQLException
SQLException
public void update()
throws SQLException
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.
SQLException
public void delete()
throws SQLException
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.
SQLException
public void close()
throws SQLException
SQLException
public ArrayList<V> toArrayList(int maxElements)
throws SQLException
maxElements - limitation for result array size (and also for number
of fetched records)
SQLException
public ArrayList<V> toArrayList()
throws SQLException
SQLException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||