|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
T
- The type of aggregate this repository stores.public interface Repository<T>
The repository provides an abstraction of the storage of aggregates.
Method Summary | |
---|---|
void |
add(T aggregate)
Adds the given aggregate to the repository. |
T |
load(Object aggregateIdentifier)
Load the aggregate with the given unique identifier. |
T |
load(Object aggregateIdentifier,
Long expectedVersion)
Load the aggregate with the given unique aggregateIdentifier , expecting the version of the aggregate
to be equal to the given expectedVersion . |
Method Detail |
---|
T load(Object aggregateIdentifier, Long expectedVersion)
aggregateIdentifier
, expecting the version of the aggregate
to be equal to the given expectedVersion
. If the expectedVersion
is null
,
no version validation is done.
When versions do not match, implementations may either raise an exception immediately when loading an aggregate,
or at any other time while the aggregate is registered in the current Unit Of Work.
aggregateIdentifier
- The identifier of the aggregate to loadexpectedVersion
- The expected version of the aggregate to load, or null
to indicate the
version should not be checked
AggregateNotFoundException
- if aggregate with given id cannot be found
ConflictingModificationException
- if the expectedVersion
did not match the aggregate's actual
versionUnitOfWork
T load(Object aggregateIdentifier)
aggregateIdentifier
- The identifier of the aggregate to load
AggregateNotFoundException
- if aggregate with given id cannot be foundvoid add(T aggregate)
aggregate
to the repository. The version of this aggregate must be null
,
indicating that it has not been previously persisted.
This method will not force the repository to save the aggregate immediately. Instead, it is registered with the
current UnitOfWork. To force storage of an aggregate, commit the current unit of work
(CurrentUnitOfWork.commit()
)
aggregate
- The aggregate to add to the repository.
IllegalArgumentException
- if the given aggregate is not newly created. This means AggregateRoot.getVersion()
must return
null
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |