|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.j256.ormlite.dao.BaseForeignCollection<T,ID>
com.j256.ormlite.dao.LazyForeignCollection<T,ID>
public class LazyForeignCollection<T,ID>
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.
Field Summary |
---|
Fields inherited from class com.j256.ormlite.dao.BaseForeignCollection |
---|
dao |
Constructor Summary | |
---|---|
LazyForeignCollection(Dao<T,ID> dao,
String fieldName,
Object fieldValue,
String orderColumn,
Object parent)
|
Method Summary | ||
---|---|---|
CloseableIterator<T> |
closeableIterator()
Returns an iterator over a set of elements of type T which can be closed. |
|
void |
closeLastIterator()
This will close the last iterator returned by the Collection.iterator() method. |
|
boolean |
contains(Object obj)
|
|
boolean |
containsAll(Collection<?> collection)
|
|
boolean |
equals(Object other)
This is just a call to Object.equals(Object) . |
|
CloseableWrappedIterable<T> |
getWrappedIterable()
This makes a one time use iterable class that can be closed afterwards. |
|
int |
hashCode()
This is just a call to Object.hashCode() . |
|
boolean |
isEager()
Returns true if this an eager collection otherwise false. |
|
boolean |
isEmpty()
|
|
CloseableIterator<T> |
iterator()
The iterator returned from a lazy collection keeps a connection open to the database as it iterates across the collection. |
|
CloseableIterator<T> |
iteratorThrow()
This is the same as iterator() except it throws. |
|
boolean |
remove(Object data)
Remove the item from the collection and the associated database table. |
|
boolean |
removeAll(Collection<?> collection)
Remove the items in the collection argument from the foreign collection and the associated database table. |
|
CloseableIterator<T> |
seperateIteratorThrow()
Same as iteratorThrow() except this doesn't set the last iterator which can be closed with the
closeLastIterator() . |
|
int |
size()
|
|
Object[] |
toArray()
|
|
|
toArray(E[] array)
|
Methods inherited from class com.j256.ormlite.dao.BaseForeignCollection |
---|
add, addAll, clear, getPreparedQuery, retainAll |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Collection |
---|
add, addAll, clear, retainAll |
Constructor Detail |
---|
public LazyForeignCollection(Dao<T,ID> dao, String fieldName, Object fieldValue, String orderColumn, Object parent)
Method Detail |
---|
public CloseableIterator<T> iterator()
CloseableIterator.close()
or go all the way through the loop to ensure
that the connection has been closed. You can also call closeLastIterator()
on the collection itself
which will close the last iterator returned. See the reentrant warning.
iterator
in interface Iterable<T>
iterator
in interface Collection<T>
public CloseableIterator<T> closeableIterator()
CloseableIterable
closeableIterator
in interface CloseableIterable<T>
public CloseableIterator<T> iteratorThrow() throws SQLException
iterator()
except it throws.
iteratorThrow
in interface ForeignCollection<T>
SQLException
public CloseableIterator<T> seperateIteratorThrow() throws SQLException
iteratorThrow()
except this doesn't set the last iterator which can be closed with the
closeLastIterator()
.
SQLException
public CloseableWrappedIterable<T> getWrappedIterable()
ForeignCollection
CloseableWrappedIterable
but multiple threads can each call this to get their own closeable iterable.
getWrappedIterable
in interface ForeignCollection<T>
public void closeLastIterator() throws SQLException
ForeignCollection
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 ForeignCollection.getWrappedIterable()
to get a reentrant wrapped
iterable for each thread instead.
closeLastIterator
in interface ForeignCollection<T>
SQLException
public boolean isEager()
ForeignCollection
isEager
in interface ForeignCollection<T>
public int size()
size
in interface Collection<T>
public boolean isEmpty()
isEmpty
in interface Collection<T>
public boolean contains(Object obj)
contains
in interface Collection<T>
public boolean containsAll(Collection<?> collection)
containsAll
in interface Collection<T>
public boolean remove(Object data)
BaseForeignCollection
remove
in interface Collection<T>
remove
in class BaseForeignCollection<T,ID>
public boolean removeAll(Collection<?> collection)
BaseForeignCollection
removeAll
in interface Collection<T>
removeAll
in class BaseForeignCollection<T,ID>
public Object[] toArray()
toArray
in interface Collection<T>
public <E> E[] toArray(E[] array)
toArray
in interface Collection<T>
public boolean equals(Object other)
Object.equals(Object)
.
NOTE: This method is here for documentation purposes because EagerForeignCollection.equals(Object)
is
defined.
equals
in interface Collection<T>
equals
in class Object
public int hashCode()
Object.hashCode()
.
NOTE: This method is here for documentation purposes because EagerForeignCollection.equals(Object)
is
defined.
hashCode
in interface Collection<T>
hashCode
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |