A
- Aggregate root class.ID
- Identifier class.public abstract class BaseMorphiaRepository<A extends AggregateRoot<ID>,ID> extends BaseRepository<A,ID>
getDatastore()
()} protected method.Repository.Option
Constructor and Description |
---|
BaseMorphiaRepository() |
BaseMorphiaRepository(Class<A> aggregateRootClass,
Class<ID> kClass) |
Modifier and Type | Method and Description |
---|---|
void |
add(A aggregate)
Adds an aggregate to the repository.
|
A |
addOrUpdate(A aggregate)
Adds an aggregate to the repository or updates it if it already exists.
|
void |
clear()
Removes all aggregates from the repository.
|
boolean |
contains(ID id)
Checks that the aggregate identified by the specified identifier is present in the repository.
|
boolean |
contains(Specification<A> specification)
Check if at least one aggregate satisfying the specified specification is present in the
repository.
|
long |
count(Specification<A> specification)
Count the number of aggregates in the repository satisfying the given specification.
|
Optional<A> |
get(ID id)
Gets an aggregate identified by its identifier.
|
Stream<A> |
get(Specification<A> specification,
Repository.Option... options)
Finds all aggregates in the repository satisfying the given specification.
|
protected org.mongodb.morphia.Datastore |
getDatastore()
Provides access to the Morphia data store for implementing custom data access methods.
|
void |
remove(ID id)
Removes the existing aggregate identified with the specified identifier.
|
long |
remove(Specification<A> specification)
Removes all aggregates in the repository satisfying the given specification.
|
long |
size()
Returns the number of aggregates in the repository.
|
A |
update(A aggregate)
Updates an existing aggregate with the specified instance.
|
getAggregateRootClass, getIdentifierClass, getSpecificationBuilder
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
contains, isEmpty, remove
protected org.mongodb.morphia.Datastore getDatastore()
public void add(A aggregate) throws AggregateExistsException
Repository
aggregate
- the aggregate to add.AggregateExistsException
- if the repository already contains the aggregate.public Stream<A> get(Specification<A> specification, Repository.Option... options)
Repository
specification
- the specification aggregates must satisfy.options
- result options.Repository.Option
public Optional<A> get(ID id)
Repository
id
- the aggregate identifier.public boolean contains(Specification<A> specification)
Repository
specification
- the specification.public boolean contains(ID id)
Repository
id
- the aggregate identifier.public long count(Specification<A> specification)
Repository
specification
- the specification aggregates must satisfy.public long size()
Repository
public long remove(Specification<A> specification) throws AggregateNotFoundException
Repository
specification
- the specification aggregates must satisfy.AggregateNotFoundException
- if the repository doesn't contain the aggregate.public void remove(ID id) throws AggregateNotFoundException
Repository
id
- the identifier of the aggregate to remove.AggregateNotFoundException
- if the repository doesn't contain the aggregate.public A update(A aggregate) throws AggregateNotFoundException
Repository
aggregate
- the aggregate to update.AggregateNotFoundException
- if the repository doesn't contain the aggregate.public A addOrUpdate(A aggregate)
Repository
Repository.add(A)
and Repository.update(AggregateRoot)
should
be preferred.aggregate
- the aggregate to update.public void clear()
Repository
Copyright © 2013-2018–2019 SeedStack. All rights reserved.