I - type of the persistent object and transport object id. This type
should be immutable. It is critical this type implements equals()
and hashCode() correctly.P - type of model persistent object.T - type of the transport object.F - type of the associated filter.S - type of the associated sort specification type.public abstract class AbstractDao<I extends Serializable,P extends Storable<I>,T extends Transportable<? super T,I>,F,S> extends AbstractBaseDao<I,P,T,F,S> implements Dao<I,P,T,F,S>
This class must remain state-less so it is thread safe.
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractDao(Class<P> entityClass)
Construct DAO and initialize query predicate generator.
|
protected |
AbstractDao(Class<P> entityClass,
UpdateStrategy<P,T> updateStrategy)
Construct DAO and initialize query predicate generator.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
conform(P target,
T source)
Synchronizes the transport object and the persistent object state.
|
T |
convert(P source)
Converts an instance of type S to an instance of type T
|
P |
create(T transportable,
DataStoreContext context)
Creates a new persistent object with the data from the given transport
object.
|
protected abstract P |
createStorableInstance(T transportable)
Creates the instance of the persistent object (Entity).
|
long |
delete(F filter,
DataStoreContext context)
Deletes all persistent objects matching the given filter.
|
boolean |
delete(Id<T,I> id,
DataStoreContext context)
Deletes the persistent object with the given id.
|
void |
delete(P storable,
DataStoreContext context)
Deletes a persistent object.
|
long |
deleteAll(DataStoreContext context)
Deletes all the persistent objects.
|
protected abstract T |
doConvert(P source)
Converts the persistent object to a transport object.
|
P |
update(T transportable,
DataStoreContext context)
Updates the persistent object related to the given transport object.
|
count, find, find, findAll, get, getQueryPredicate, getQueryPredicateGenerator, getSingularAttribute, updateDependentsprotected AbstractDao(Class<P> entityClass)
entityClass - persistent object class.protected AbstractDao(Class<P> entityClass, UpdateStrategy<P,T> updateStrategy)
entityClass - persistent object class.updateStrategy - update strategy.public P create(T transportable, DataStoreContext context)
Daopublic P update(T transportable, DataStoreContext context)
Daopublic void delete(P storable, DataStoreContext context)
DaoConcrete classes could override this method to do any pre-processing / post-processing work.
public boolean delete(Id<T,I> id, DataStoreContext context)
Daopublic long delete(F filter, DataStoreContext context)
Daopublic long deleteAll(DataStoreContext context)
Daopublic T convert(P source)
Converterprotected abstract P createStorableInstance(T transportable)
transportable - transport object to get the data from.protected abstract T doConvert(P source)
source - persistent object to convert.sourceprotected abstract void conform(P target, T source)
update(Transportable, DataStoreContext),
thus if update(Transportable, DataStoreContext) is overwritten
this method could have an empty implementation.target - object to update.source - object to take the data from.Copyright © 2014. All Rights Reserved.