public abstract class BaseForeignCollection<T,ID> extends Object implements ForeignCollection<T>, Serializable
ForeignCollectionField
annotation when an
object is refreshed or queried (i.e. not created).
WARNING: Most likely for(;;) loops should not be used here since we need to be careful about closing the iterator.
Modifier | Constructor and Description |
---|---|
protected |
BaseForeignCollection(Dao<T,ID> dao,
Object parent,
Object parentId,
FieldType foreignFieldType,
String orderColumn,
boolean orderAscending) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(T data)
Adds the object to the collection.
|
boolean |
addAll(Collection<? extends T> collection)
Add the collection of elements to this collection.
|
void |
clear()
Clears the collection and uses the iterator to run through the dao and delete all of the items in the collection
from the associated database table.
|
Dao<T,?> |
getDao()
Return the DAO object associated with this foreign collection.
|
protected PreparedQuery<T> |
getPreparedQuery() |
int |
refresh(T data)
This is a call through to
Dao.refresh(Object) using the internal collection DAO. |
abstract boolean |
remove(Object data)
Remove the item from the collection and the associated database table.
|
abstract boolean |
removeAll(Collection<?> collection)
Remove the items in the collection argument from the foreign collection and the associated database table.
|
boolean |
retainAll(Collection<?> collection)
Uses the iterator to run through the dao and retain only the items that are in the passed in collection.
|
int |
update(T data)
This is a call through to
Dao.update(Object) using the internal collection DAO. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
closeableIterator, closeLastIterator, getWrappedIterable, getWrappedIterable, isEager, iterator, iteratorThrow, iteratorThrow, refreshAll, refreshCollection, updateAll
contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, removeIf, size, spliterator, stream, toArray, toArray
closeableIterator
public boolean add(T data)
ForeignCollection
Dao.create(Object)
. If the object has already been created in the database then you just need to set the
foreign field on the object and call Dao.update(Object)
. If you add it here the DAO will try to create it
in the database again which will most likely cause an error.add
in interface ForeignCollection<T>
add
in interface Collection<T>
Collection.add(Object)
public boolean addAll(Collection<? extends T> collection)
addAll
in interface Collection<T>
public abstract boolean remove(Object data)
remove
in interface Collection<T>
public abstract boolean removeAll(Collection<?> collection)
removeAll
in interface Collection<T>
public boolean retainAll(Collection<?> collection)
retainAll
in interface Collection<T>
public void clear()
clear
in interface Collection<T>
public int update(T data) throws SQLException
ForeignCollection
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.update
in interface ForeignCollection<T>
SQLException
public int refresh(T data) throws SQLException
ForeignCollection
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.refresh
in interface ForeignCollection<T>
SQLException
public Dao<T,?> getDao()
ForeignCollection
getDao
in interface ForeignCollection<T>
protected PreparedQuery<T> getPreparedQuery() throws SQLException
SQLException
This documentation is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.