|
||||||||||
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. |
int |
refresh(T obj)
This is a call through to Dao.refresh(Object) using the internal collection DAO. |
int |
refreshAll()
Call to refresh on all of the items currently in the collection with the database. |
int |
refreshCollection()
This re-issues the query that initially built the collection replacing any underlying result collection with a new one build from the database. |
int |
update(T obj)
This is a call through to Dao.update(Object) using the internal collection DAO. |
int |
updateAll()
Update all of the items currently in the collection with the database. |
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()
int update(T obj) throws SQLException
Dao.update(Object)
using the internal collection DAO. Objects inside of the
collection are not updated if the parent object is refreshed so you will need to so that by hand.
SQLException
int updateAll() throws SQLException
SQLException
int refresh(T obj) throws SQLException
Dao.refresh(Object)
using the internal collection DAO. Objects inside of the
collection are not refreshed if the parent object is refreshed so you will need to so that by hand.
SQLException
int refreshAll() throws SQLException
refreshCollection()
.
SQLException
int refreshCollection() throws SQLException
SQLException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |