A - Aggregate root classI - Identifier classpublic abstract class BaseJpaRepository<A extends AggregateRoot<I>,I> extends BaseRepository<A,I>
getEntityManager()
protected method.Repository.Option| Modifier | Constructor and Description |
|---|---|
|
BaseJpaRepository()
Default constructor.
|
protected |
BaseJpaRepository(Class<A> aggregateRootClass,
Class<I> idClass)
This protected constructor is intended to be used by JPA repositories that already know their
aggregate root and key classes.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(A aggregate)
Adds an aggregate to the repository.
|
void |
clear()
Removes all aggregates from the repository.
|
boolean |
contains(A aggregate)
Checks that the specified aggregate is present in the repository.
|
boolean |
contains(I 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(I 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 javax.persistence.EntityManager |
getEntityManager()
Provides access to the entity manager for implementing custom data access methods.
|
boolean |
isEmpty()
Return true if the repository is empty (i.e.
|
void |
remove(A aggregate)
Removes the specified aggregate from the repository.
|
void |
remove(I 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, getSpecificationBuilderclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddOrUpdatepublic BaseJpaRepository()
protected BaseJpaRepository(Class<A> aggregateRootClass, Class<I> idClass)
DefaultJpaRepository for providing a default JPA repository for all
aggregates.aggregateRootClass - the aggregate root class.idClass - the id class.protected javax.persistence.EntityManager getEntityManager()
public void add(A aggregate) throws AggregateExistsException
Repositoryaggregate - the aggregate to add.AggregateExistsException - if the repository already contains the aggregate.public Stream<A> get(Specification<A> specification, Repository.Option... options)
Repositoryspecification - the specification aggregates must satisfy.options - result options.Repository.Optionpublic Optional<A> get(I id)
Repositoryid - the aggregate identifier.public boolean contains(Specification<A> specification)
Repositoryspecification - the specification.public boolean contains(I id)
Repositoryid - the aggregate identifier.public boolean contains(A aggregate)
Repositorycontains(aggregate.getId()
).aggregate - the aggregate identifier.public long count(Specification<A> specification)
Repositoryspecification - the specification aggregates must satisfy.public long size()
Repositorypublic boolean isEmpty()
Repositorypublic long remove(Specification<A> specification)
Repositoryspecification - the specification aggregates must satisfy.public void remove(I id) throws AggregateNotFoundException
Repositoryid - the identifier of the aggregate to remove.AggregateNotFoundException - if the repository doesn't contain the aggregate.public void remove(A aggregate) throws AggregateNotFoundException
Repositoryaggregate - the aggregate to remove.AggregateNotFoundException - if the repository doesn't contain the aggregate.public A update(A aggregate) throws AggregateNotFoundException
Repositoryaggregate - the aggregate to update.AggregateNotFoundException - if the repository doesn't contain the aggregate.public void clear()
RepositoryCopyright © 2013-2018–2019 SeedStack. All rights reserved.