|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.northwestern.at.utils.db.hibernate.HibernateScrollIterator
public class HibernateScrollIterator
Wraps a Hibernate ScrollableResults with a standard iterator.
Hibernate supported cursored result sets using the ScrollableResults interface. Cursored results sets do not require that the entire set of query results be retrieved to memory in one piece. In many cases, all one wants is to be able to iterate through the results in the usual fashion. This class wraps a Hibernate ScrollableResults with a standard Java Iterator to support simple sequential access.
Example:
PersistenceManager pm = new PersistenceManager();
ScrollableResults r = pm.scrollableQuery( ... );
HibernateScrollIterator iterator = new HibernateScrollIterator( r );
while ( iterator.hasNext() )
{
Object o = iterator.next();
...
}
iterator.close();
You may call the close() method explicitly as above to release the ScrollableResults object and its associated database cursor. These will also be released implicitly when the HibernateScrollIterator is finalized.
Field Summary | |
---|---|
protected boolean |
isClosed
True if the ScrollableResults object has been closed. |
protected java.lang.Object |
nextRow
The next database row to return. |
protected org.hibernate.ScrollableResults |
scrollableResults
The Hibernate ScrollableResults object through which to iterate. |
Constructor Summary | |
---|---|
HibernateScrollIterator(org.hibernate.ScrollableResults scrollableResults)
Wrap a Hibernate ScrollableResults with an iterator. |
Method Summary | |
---|---|
void |
close()
Close the Hibernate ScrollableResults field. |
protected void |
finalize()
Handle object destruction. |
boolean |
hasNext()
Iterator interface method: is there another database row available? |
boolean |
isClosed()
Check if scrollable results closed. |
java.lang.Object |
next()
Iterator interface method: return next row of data. |
void |
remove()
Iterator interdace method; Remove current entry -- Not supported. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected org.hibernate.ScrollableResults scrollableResults
protected boolean isClosed
protected java.lang.Object nextRow
Constructor Detail |
---|
public HibernateScrollIterator(org.hibernate.ScrollableResults scrollableResults)
scrollableResults
- The Hibernate scrollable results to
wrap with an iterator. Method Detail |
---|
public boolean hasNext()
hasNext
in interface java.util.Iterator
public java.lang.Object next()
next
in interface java.util.Iterator
public void remove()
remove
in interface java.util.Iterator
java.lang.UnsupportedOperationException
- always public void close()
public boolean isClosed()
protected void finalize() throws java.lang.Throwable
Releases the Hibernate ScrollableResults before performing the usual finalization.
finalize
in class java.lang.Object
java.lang.Throwable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |