|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ForeignCollection<T>
Collection that is set on a field that as been marked with the ForeignCollectionField
annotation when an
object is refreshed or queried (i.e. not created).
@ForeignCollectionField(eager = false) private ForeignCollection<Order> orders;
NOTE: If the collection has been marked as being "lazy" then just about all methods in this class result in a
pass through the database using the Collection.iterator()
. Even Collection.size()
and other seemingly simple calls can
cause a lot of database I/O. Most likely just the Collection.iterator()
, Collection.toArray()
, and
Collection.toArray(Object[])
methods should be used if you are using a lazy collection. Any other methods have no
guarantee to be at all efficient. Take a look at the source if you have any question.
NOTE: It is also important to remember that lazy iterators hold a connection open to the database which needs
to be closed. See LazyForeignCollection.iterator()
.
Method Summary | |
---|---|
void |
closeLastIterator()
This will close the last iterator returned by the Collection.iterator() method. |
CloseableWrappedIterable<T> |
getWrappedIterable()
This makes a one time use iterable class that can be closed afterwards. |
boolean |
isEager()
Returns true if this an eager collection otherwise false. |
CloseableIterator<T> |
iteratorThrow()
Like Collection.iterator() but returns a closeable iterator instead and can throw a SQLException. |
Methods inherited from interface java.util.Collection |
---|
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
Methods inherited from interface com.j256.ormlite.dao.CloseableIterable |
---|
closeableIterator |
Method Detail |
---|
CloseableIterator<T> iteratorThrow() throws SQLException
Collection.iterator()
but returns a closeable iterator instead and can throw a SQLException.
SQLException
CloseableWrappedIterable<T> getWrappedIterable()
CloseableWrappedIterable
but multiple threads can each call this to get their own closeable iterable.
void closeLastIterator() throws SQLException
Collection.iterator()
method.
NOTE: For lazy collections, this is not reentrant. If multiple threads are getting iterators from a lazy
collection from the same object then you should use getWrappedIterable()
to get a reentrant wrapped
iterable for each thread instead.
SQLException
boolean isEager()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |