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 the persistent objectT
- type of the transport object with a reference to the ownerQ
- type of the transport object with a reference to the owner's idF
- type of the associated filterS
- type of the associated sort specification typeE
- type of the owner persistent object and owner transport object
id. This type should be immutable. It is critical this type
implements equals() and hashCode() correctlyW
- type of the owner persistent objectR
- type of the owner transport objectpublic interface BidirectionalDependentDao<I extends Serializable,P extends Storable<I> & Dependable<E>,T extends Transportable<? super T,I> & Dependent<R>,Q extends Transportable<? super Q,I> & Dependent<E>,F,S,E extends Serializable,W extends Storable<E>,R extends Transportable<? super R,E>> extends BaseDao<I,P,T,F,S>, Converter<P,Q>
Modifier and Type | Method and Description |
---|---|
T |
convert(P storable,
BaseDao<E,W,R,?,?> ownerDao,
Converter<W,R> ownerConverter,
DataStoreContext context)
Converts the storable object to a transportable.
|
T |
convert(P storable,
R owner)
Converts the storable object to a transportable.
|
P |
create(T transportable,
W owner,
DataStoreContext context)
Creates a new persistent object with the data from the given transport
object.
|
void |
update(P target,
T source,
DataStoreContext context)
Updates the persistent object related to the given transport object.
|
P |
update(Q transportable,
DataStoreContext context)
Updates the persistent object related to the given transport object.
|
P create(T transportable, W owner, DataStoreContext context)
transportable
- transport object to get the data from.owner
- ownercontext
- data store contextvoid update(P target, T source, DataStoreContext context)
target
- object to updatesource
- object to take the data fromcontext
- data store contextP update(Q transportable, DataStoreContext context)
transportable
- transport object to get the data fromcontext
- data store contextT convert(P storable, R owner)
storable
- storable object to convertowner
- the storable object's ownerT convert(P storable, BaseDao<E,W,R,?,?> ownerDao, Converter<W,R> ownerConverter, DataStoreContext context)
Example when owner is a Dao
Dao<E, W, R, ?, ?> ownerDao = ...; BidirectionalDependentDao<I, P, T, ?, ?, ?, E, W, R> dependentDao = ...; DataStoreContext context = ...; P storable = ...; T transportable = dependentDao.convert(storable, ownerDao, ownerDao, context);Example when owner is a
BidirectionalDependentDao
final Dao<H, M, N, ?, ?> rootOwnerDao = ...; final BidirectionalDependentDao<E, W, R, ?, ?, ?, H, M, N> dependentOwnerDao = ...; BidirectionalDependentDao<I, P, T, ?, ?, ?, E, W, R> dependentDao = ...; final DataStoreContext context = ...; Converter<W, R> dependentOwnerConverter = new Converter<W, R>() { @Override public R convert(W source) { return dependentOwnerDao.convert(source, rootOwnerDao, rootOwnerDao, context); } }; P storable = ...; T transportable = dependentDao.convert(storable, dependentOwnerDao, dependentOwnerConverter, context);
storable
- storable object to convertownerDao
- owner dao to load the owner from the databaseownerConverter
- converter to use to convert the owner persistent
object to a transport objectcontext
- data store contextCopyright © 2015. All Rights Reserved.