org.qi4j.spi.entitystore

## Class ModuleEntityStoreUnitOfWork

- java.lang.Object
- - org.qi4j.spi.entitystore.ModuleEntityStoreUnitOfWork

- All Implemented Interfaces:
    EntityStoreUnitOfWork

      public class ModuleEntityStoreUnitOfWork
      extends Object
      implements EntityStoreUnitOfWork

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ModuleEntityStoreUnitOfWork(ModuleSpi module, EntityStoreUnitOfWork underlying)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `StateCommitter` | `applyChanges()`
    `long` | `currentTime()`
    `void` | `discard()`
    `EntityState` | `entityStateOf(ModuleSpi module, EntityReference reference)` Get the EntityState for a given identity.
    `String` | `identity()`
    `ModuleSpi` | `module()`
    `EntityState` | `newEntityState(ModuleSpi module, EntityReference reference, EntityDescriptor descriptor)` Create new EntityState for a given identity.
    `Usecase` | `usecase()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ModuleEntityStoreUnitOfWork

          public ModuleEntityStoreUnitOfWork(ModuleSpi module,
                                     EntityStoreUnitOfWork underlying)

  - ### Method Detail

    - #### module

          public ModuleSpi module()

    - #### identity

          public String identity()

      Specified by:
        `identity` in interface `EntityStoreUnitOfWork`

    - #### currentTime

          public long currentTime()

      Specified by:
        `currentTime` in interface `EntityStoreUnitOfWork`

    - #### newEntityState

          public EntityState newEntityState(ModuleSpi module,
                                   EntityReference reference,
                                   EntityDescriptor descriptor)
                                     throws EntityStoreException

      Description copied from interface: `EntityStoreUnitOfWork`
      Create new EntityState for a given identity.

      This should only create the EntityState and not insert it into any database, since that should occur during the `EntityStoreUnitOfWork.applyChanges()` call.

      Specified by:
        `newEntityState` in interface `EntityStoreUnitOfWork`
        `reference` - the identity of the entity
        `descriptor` - entity descriptor
      Returns:
        The new entity state.
      Throws:
        `EntityStoreException` - Thrown if creational fails.

    - #### entityStateOf

          public EntityState entityStateOf(ModuleSpi module,
                                  EntityReference reference)
                                    throws EntityStoreException,
                                           EntityNotFoundException

      Description copied from interface: `EntityStoreUnitOfWork`
      Get the EntityState for a given identity. Throws `EntityNotFoundException` if the entity with given `anIdentity` is not found.
      Specified by:
        `entityStateOf` in interface `EntityStoreUnitOfWork`
        `reference` - The entity identity. This argument must not be `null`.
      Returns:
        Entity state given the composite descriptor and identity.
      Throws:
        `EntityStoreException` - thrown if retrieval failed.
        `EntityNotFoundException` - if requested entity does not exist

    - #### applyChanges

          public StateCommitter applyChanges()
                                      throws EntityStoreException

      Specified by:
        `applyChanges` in interface `EntityStoreUnitOfWork`
      Throws:
        `EntityStoreException`

    - #### discard

          public void discard()

      Specified by:
        `discard` in interface `EntityStoreUnitOfWork`

    - #### usecase

          public Usecase usecase()

      Specified by:
        `usecase` in interface `EntityStoreUnitOfWork`