com.h3c.util.dao

## 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>>

- Type Parameters:
    `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 object
    `T` - type of the transport object with a reference to the owner
    `Q` - type of the transport object with a reference to the owner's id
    `F` - type of the associated filter
    `S` - type of the associated sort specification type
    `E` - 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() correctly
    `W` - type of the owner persistent object
    `R` - type of the owner transport object
  All Superinterfaces:
    BaseDao<I,P,T,F,S>, Converter<P,Q>
  All Known Implementing Classes:
    AbstractBidirectionalDependentDao

      public 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>

  Data Access Object for a storable that is the dependent object in a one-to-many bidirectional relation.

- - ### Method Summary

    Methods
    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.

    - ### Methods inherited from interface com.h3c.util.dao.BaseDao

      `count, find, find, findAll, get`

    - ### Methods inherited from interface com.h3c.util.Converter

      `convert`

- - ### Method Detail

    - #### create

          P create(T transportable,
                 W owner,
                 DataStoreContext context)

      Creates a new persistent object with the data from the given transport object.
      Parameters:
        `transportable` - transport object to get the data from.
        `owner` - owner
        `context` - data store context
      Returns:
        the new created persistent object

    - #### update

          void update(P target,
                    T source,
                    DataStoreContext context)

      Updates the persistent object related to the given transport object. This method is meant to be called by the owner. No need to re-load the dependent storable since the owner already loads it.
      Parameters:
        `target` - object to update
        `source` - object to take the data from
        `context` - data store context

    - #### update

          P update(Q transportable,
                 DataStoreContext context)

      Updates the persistent object related to the given transport object.
      Parameters:
        `transportable` - transport object to get the data from
        `context` - data store context
      Returns:
        the updated persistent object

    - #### convert

          T convert(P storable,
                  R owner)

      Converts the storable object to a transportable.
      Parameters:
        `storable` - storable object to convert
        `owner` - the storable object's owner
      Returns:
        the transport object representing the state of the given storable

    - #### convert

          T convert(P storable,
                  BaseDao<E,W,R,?,?> ownerDao,
                  Converter<W,R> ownerConverter,
                  DataStoreContext context)

      Converts the storable object to a transportable. This call will load the owner from the database.

      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);

      Parameters:
        `storable` - storable object to convert
        `ownerDao` - owner dao to load the owner from the database
        `ownerConverter` - converter to use to convert the owner persistent object to a transport object
        `context` - data store context
      Returns:
        the transport object representing the state of the given storable

Copyright © 2014. All Rights Reserved.