Package net.sf.basedb.core
Class DataResultIterator<I extends BasicData>
java.lang.Object
net.sf.basedb.core.DataResultIterator<I>
- All Implemented Interfaces:
AutoCloseable
,Iterator<I>
,QueryResult
,ResultIterator<I>
Return the results of a
DataQuery
as an iterator. This type
of iterator is only used for batchable items like reporter and raw data.
It is expected that the query uses the stateless Hibernate session available
from DbControl.getStatelessSession()
. If not,
the returned objects are automatically disconnected from the Hibernate session
to avoid memory problems and bypassing permission checks.- Version:
- 2.0
- Author:
- Samuel, Nicklas
- See Also:
- Last modified
- $Date: 2012-09-14 09:28:35 +0200 (fr, 14 sep 2012) $
-
Field Summary
Modifier and TypeFieldDescriptionprivate final ScrollIterator<I>
The internal iterator of BasicData objects.The class of the data objects returned by the query (and this object).private final Item
The type of items returned by the query.private final SessionControl
The SessionControlprivate final Session
The Hibernate Session that was used in the query, null if a stateless session is used.private final long
The total number of items. -
Constructor Summary
ConstructorDescriptionDataResultIterator
(ScrollIterator<I> data, SessionControl sc, Session session, Class<I> dataClass, long totalCount) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
From the ResultIterator interface ---------------------------------Get the type of items contained in this list.long
From the QueryResult interface ---------------------------------boolean
hasNext()
boolean
isClosed()
Check if the iterator has been closed.next()
void
remove()
Not supported.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
data
The internal iterator of BasicData objects. -
session
The Hibernate Session that was used in the query, null if a stateless session is used. -
sc
The SessionControl -
totalCount
private final long totalCountThe total number of items. -
dataClass
The class of the data objects returned by the query (and this object). -
itemType
The type of items returned by the query.
-
-
Constructor Details
-
DataResultIterator
DataResultIterator(ScrollIterator<I> data, SessionControl sc, Session session, Class<I> dataClass, long totalCount)
-
-
Method Details
-
getTotalCount
public long getTotalCount()From the QueryResult interface ---------------------------------- Specified by:
getTotalCount
in interfaceQueryResult
- Returns:
- The total number of items, or -1 if not known
- See Also:
-
close
public void close()From the ResultIterator interface ---------------------------------- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceResultIterator<I extends BasicData>
-
isClosed
public boolean isClosed()Description copied from interface:ResultIterator
Check if the iterator has been closed.- Specified by:
isClosed
in interfaceResultIterator<I extends BasicData>
-
hasNext
public boolean hasNext() -
next
-
remove
public void remove()Not supported.- Specified by:
remove
in interfaceIterator<I extends BasicData>
- Throws:
UnsupportedOperationException
- Always
-
getItemType
Get the type of items contained in this list.- Returns:
- An
Item
object or null if not known
-