com.j256.ormlite.dao
Interface ForeignCollection<T>

All Superinterfaces:
Collection<T>, Iterable<T>
All Known Implementing Classes:
BaseForeignCollection, EagerForeignCollection, LazyForeignCollection

public interface ForeignCollection<T>
extends Collection<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 iterator(). Even Collection.size() and other seemingly simple calls can cause a lot of database I/O. Most likely just the iterator(), Collection.toArray(), and Collection.toArray(Object[]) methods should be used if you are using a lazy collection.

Author:
graywatson

Method Summary
 CloseableIterator<T> iterator()
          Like Collection.iterator() but returns a closeable iterator instead.
 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, remove, removeAll, retainAll, size, toArray, toArray
 

Method Detail

iterator

CloseableIterator<T> iterator()
Like Collection.iterator() but returns a closeable iterator instead. This may throw RuntimeException if there is any SQL exceptions unfortunately.

Specified by:
iterator in interface Collection<T>
Specified by:
iterator in interface Iterable<T>

iteratorThrow

CloseableIterator<T> iteratorThrow()
                                   throws SQLException
Like Collection.iterator() but returns a closeable iterator instead and can throw a SQLException.

Throws:
SQLException


Copyright © 2011. All Rights Reserved.