|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.ojb.broker.accesslayer.RsIterator
RsIterator can be used to iterate over a jdbc ResultSet to retrieve persistent objects step-by-step and not all at once. In fact the PersistenceBroker::getCollectionByQuery(...) method uses a RsIterator internally to build up a Collection of objects
NOTE: OJB is very strict in handling RsIterator instances. RsIterator is
bound very closely to the used PersistenceBroker
instance.
Thus if you do a
- PersistenceBroker.close()
- PersistenceBroker.commitTransaction()
- PersistenceBroker.abortTransaction()
call, the current RsIterator instance resources will be cleaned up automatic
and invalidate current instance.
NOTE: this code uses features that only JDBC 2.0 compliant Drivers support. It will NOT work with JDBC 1.0 Drivers (e.g. SUN's JdbcOdbcDriver) If you are forced to use such a driver, you can use code from the 0.1.30 release.
Nested Class Summary | |
static class |
RsIterator.ResourceClosedException
|
static class |
RsIterator.ResourceNotClosedException
|
static class |
RsIterator.ResourceWrapper
Wraps a RsIterator instance as WeakReference . |
Constructor Summary | |
RsIterator(RsQueryObject queryObject,
PersistenceBrokerImpl broker)
RsIterator constructor. |
Method Summary | |
boolean |
absolute(int row)
Moves the cursor to the given row number in the iterator. |
void |
disableLifeCycleEvents()
Do not fire any PBLifeCycleEvent when reading next item. |
int |
fullSize()
|
ClassDescriptor |
getClassDescriptor()
|
boolean |
hasNext()
returns true if there are still more rows in the underlying ResultSet. |
java.lang.Object |
next()
moves to the next row of the underlying ResultSet and returns the corresponding Object materialized from this row. |
boolean |
relative(int row)
Moves the cursor a relative number of rows, either positive or negative. |
void |
releaseDbResources()
Release all internally used Database resources of the iterator. |
void |
remove()
removing is not supported |
void |
setAutoRelease(boolean autoRelease)
Allows user to switch off/on automatic resource cleanup. |
int |
size()
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public RsIterator(RsQueryObject queryObject, PersistenceBrokerImpl broker)
queryObject
- query objectbroker
- the broker we should use.Method Detail |
public boolean hasNext()
hasNext
in interface java.util.Iterator
public java.lang.Object next() throws java.util.NoSuchElementException
next
in interface java.util.Iterator
java.util.NoSuchElementException
public void remove()
remove
in interface java.util.Iterator
public int size() throws PersistenceBrokerException
size
in interface OJBIterator
PersistenceBrokerException
public int fullSize() throws PersistenceBrokerException
fullSize
in interface OJBIterator
PersistenceBrokerException
public boolean absolute(int row) throws PersistenceBrokerException
absolute
in interface OJBIterator
row
- the row to move to in this iterator, by absolute number
PersistenceBrokerException
public boolean relative(int row) throws PersistenceBrokerException
relative
in interface OJBIterator
row
- the row to move to in this iterator, by relative number
PersistenceBrokerException
public void releaseDbResources()
releaseDbResources
in interface OJBIterator
public void setAutoRelease(boolean autoRelease)
releaseDbResources()
.
public java.lang.String toString()
public ClassDescriptor getClassDescriptor()
public void disableLifeCycleEvents()
OJBIterator
disableLifeCycleEvents
in interface OJBIterator
OJBIterator.disableLifeCycleEvents()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |