com.j256.ormlite.dao
Class LazyForeignCollection<T,ID>
java.lang.Object
com.j256.ormlite.dao.BaseForeignCollection<T,ID>
com.j256.ormlite.dao.LazyForeignCollection<T,ID>
- All Implemented Interfaces:
- ForeignCollection<T>, Iterable<T>, Collection<T>
public class LazyForeignCollection<T,ID>
- extends BaseForeignCollection<T,ID>
- implements 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). Most of the methods here require a pass through the database.
Operations such as size() therefore should most likely not be used because of their expense. Chances are you only
want to use the iterator()
, toArray()
, and toArray(Object[])
methods.
WARNING: Most likely for(;;) loops should not be used here since we need to be careful about closing the
iterator.
- Author:
- graywatson
LazyForeignCollection
public LazyForeignCollection(Dao<T,ID> dao,
String fieldName,
Object fieldValue)
throws SQLException
- Throws:
SQLException
iterator
public CloseableIterator<T> iterator()
- Description copied from interface:
ForeignCollection
- 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 ForeignCollection<T>
- Specified by:
iterator
in interface Iterable<T>
- Specified by:
iterator
in interface Collection<T>
iteratorThrow
public CloseableIterator<T> iteratorThrow()
throws SQLException
- Description copied from interface:
ForeignCollection
- Like
Collection.iterator()
but returns a closeable iterator instead and can throw a SQLException.
- Specified by:
iteratorThrow
in interface ForeignCollection<T>
- Throws:
SQLException
size
public int size()
- Specified by:
size
in interface Collection<T>
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interface Collection<T>
contains
public boolean contains(Object obj)
- Specified by:
contains
in interface Collection<T>
containsAll
public boolean containsAll(Collection<?> collection)
- Specified by:
containsAll
in interface Collection<T>
toArray
public Object[] toArray()
- Specified by:
toArray
in interface Collection<T>
toArray
public <E> E[] toArray(E[] array)
- Specified by:
toArray
in interface Collection<T>
equals
public boolean equals(Object other)
- This is just a call to
Object.equals(Object)
.
- Specified by:
equals
in interface Collection<T>
- Overrides:
equals
in class Object
hashCode
public int hashCode()
- This is just a call to
Object.hashCode()
.
- Specified by:
hashCode
in interface Collection<T>
- Overrides:
hashCode
in class Object
Copyright © 2011. All Rights Reserved.