|
|||||||||
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 . |
Field Summary | |
protected Logger |
logger
|
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. |
protected void |
autoReleaseDbResources()
Internally used by this class to close used resources as soon as possible. |
protected int |
countedSize()
Answer the counted size |
protected void |
finalize()
safety just in case someone leaks. |
int |
fullSize()
|
protected PBLifeCycleEvent |
getAfterLookupEvent()
|
protected PersistenceBrokerImpl |
getBroker()
|
protected InternalCache |
getCache()
|
ClassDescriptor |
getClassDescriptor()
|
protected JdbcConnectionDescriptor |
getConnectionDescriptor()
|
protected DescriptorRepository |
getDescriptorRepository()
Return the DescriptorRepository |
protected boolean |
getHasNext()
|
protected Identity |
getIdentityFromResultSet()
returns an Identity object representing the current resultset row |
protected java.lang.Class |
getItemProxyClass()
|
protected java.lang.Object |
getObjectFromResultSet()
returns a fully materialized Object from the current row of the underlying resultset. |
protected java.lang.Object |
getProxyFromResultSet()
Reads primary key information from current RS row and generates a corresponding Identity, and returns a proxy from the Identity. |
protected RsQueryObject |
getQueryObject()
|
protected java.util.Map |
getRow()
|
protected ResultSetAndStatement |
getRsAndStmt()
|
protected java.lang.Class |
getTopLevelClass()
|
boolean |
hasNext()
returns true if there are still more rows in the underlying ResultSet. |
protected boolean |
isHasCalledCheck()
|
protected boolean |
isInBatchedMode()
|
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 |
protected void |
setAfterLookupEvent(PBLifeCycleEvent afterLookupEvent)
|
void |
setAutoRelease(boolean autoRelease)
Allows user to switch off/on automatic resource cleanup. |
protected void |
setBroker(PersistenceBrokerImpl broker)
|
protected void |
setCache(InternalCache cache)
|
protected void |
setHasCalledCheck(boolean hasCalledCheck)
|
protected void |
setHasNext(boolean hasNext)
|
protected void |
setInBatchedMode(boolean inBatchedMode)
|
protected void |
setItemProxyClass(java.lang.Class itemProxyClass)
|
protected void |
setQueryObject(RsQueryObject queryObject)
|
protected void |
setRow(java.util.Map row)
|
protected void |
setRsAndStmt(ResultSetAndStatement rsAndStmt)
|
int |
size()
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected Logger logger
Constructor Detail |
public RsIterator(RsQueryObject queryObject, PersistenceBrokerImpl broker)
queryObject
- query objectbroker
- the broker we should use.Method Detail |
protected java.lang.Class getTopLevelClass()
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
protected Identity getIdentityFromResultSet() throws PersistenceBrokerException
PersistenceBrokerException
protected java.lang.Object getObjectFromResultSet() throws PersistenceBrokerException
PersistenceBrokerException
protected java.lang.Object getProxyFromResultSet() throws PersistenceBrokerException
PersistenceBrokerException
- if there was an error creating the proxy classprotected int countedSize() throws PersistenceBrokerException
PersistenceBrokerException
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
protected void autoReleaseDbResources()
public void setAutoRelease(boolean autoRelease)
releaseDbResources()
.
protected DescriptorRepository getDescriptorRepository()
protected JdbcConnectionDescriptor getConnectionDescriptor()
protected void finalize()
public java.lang.String toString()
public ClassDescriptor getClassDescriptor()
protected void setBroker(PersistenceBrokerImpl broker)
protected PersistenceBrokerImpl getBroker()
protected void setRsAndStmt(ResultSetAndStatement rsAndStmt)
protected ResultSetAndStatement getRsAndStmt()
protected void setQueryObject(RsQueryObject queryObject)
protected RsQueryObject getQueryObject()
protected void setItemProxyClass(java.lang.Class itemProxyClass)
protected java.lang.Class getItemProxyClass()
protected void setRow(java.util.Map row)
protected java.util.Map getRow()
protected void setCache(InternalCache cache)
protected InternalCache getCache()
protected void setAfterLookupEvent(PBLifeCycleEvent afterLookupEvent)
protected PBLifeCycleEvent getAfterLookupEvent()
protected void setHasCalledCheck(boolean hasCalledCheck)
protected boolean isHasCalledCheck()
protected void setHasNext(boolean hasNext)
protected boolean getHasNext()
protected void setInBatchedMode(boolean inBatchedMode)
protected boolean isInBatchedMode()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |