Interface JdbcAggregateOperations
- All Known Implementing Classes:
JdbcAggregateTemplate
public interface JdbcAggregateOperations
Specifies a operations one can perform on a database, based on an Domain Type.
- Author:
- Jens Schauder, Thomas Lang, Milan Milanov
-
Method Summary
Modifier and TypeMethodDescriptionlong
Counts the number of aggregates of a given type.<T> void
Delete an aggregate identified by it's aggregate root.void
Delete all aggregates of a given type.<T> void
deleteById
(Object id, Class<T> domainType) Deletes a single Aggregate including all entities contained in that aggregate.<T> boolean
existsById
(Object id, Class<T> domainType) Checks if an aggregate identified by type and id exists in the database.<T> Iterable<T>
Load all aggregates of a given type.<T> Page<T>
Load a page of (potentially sorted) aggregates of a given type.<T> Iterable<T>
Load all aggregates of a given type, sorted.<T> Iterable<T>
findAllById
(Iterable<?> ids, Class<T> domainType) Load all aggregates of a given type that are identified by the given ids.<T> T
Load an aggregate from the database.<T> T
insert
(T instance) Dedicated insert function.<T> T
save
(T instance) Saves an instance of an aggregate, including all the members of the aggregate.<T> T
update
(T instance) Dedicated update function.
-
Method Details
-
save
<T> T save(T instance) Saves an instance of an aggregate, including all the members of the aggregate.- Type Parameters:
T
- the type of the aggregate root.- Parameters:
instance
- the aggregate root of the aggregate to be saved. Must not benull
.- Returns:
- the saved instance.
-
insert
<T> T insert(T instance) Dedicated insert function. This skips the test if the aggregate root is new and makes an insert.This is useful if the client provides an id for new aggregate roots.
- Type Parameters:
T
- the type of the aggregate root.- Parameters:
instance
- the aggregate root of the aggregate to be inserted. Must not benull
.- Returns:
- the saved instance.
-
update
<T> T update(T instance) Dedicated update function. This skips the test if the aggregate root is new or not and always performs an update operation.- Type Parameters:
T
- the type of the aggregate root.- Parameters:
instance
- the aggregate root of the aggregate to be inserted. Must not benull
.- Returns:
- the saved instance.
-
deleteById
Deletes a single Aggregate including all entities contained in that aggregate.- Type Parameters:
T
- the type of the aggregate root.- Parameters:
id
- the id of the aggregate root of the aggregate to be deleted. Must not benull
.domainType
- the type of the aggregate root.
-
delete
Delete an aggregate identified by it's aggregate root.- Type Parameters:
T
- the type of the aggregate root.- Parameters:
aggregateRoot
- to delete. Must not benull
.domainType
- the type of the aggregate root. Must not benull
.
-
deleteAll
Delete all aggregates of a given type.- Parameters:
domainType
- type of the aggregate roots to be deleted. Must not benull
.
-
count
Counts the number of aggregates of a given type.- Parameters:
domainType
- the type of the aggregates to be counted.- Returns:
- the number of instances stored in the database. Guaranteed to be not
null
.
-
findById
Load an aggregate from the database.- Type Parameters:
T
- the type of the aggregate root.- Parameters:
id
- the id of the aggregate to load. Must not benull
.domainType
- the type of the aggregate root. Must not benull
.- Returns:
- the loaded aggregate. Might return
null
.
-
findAllById
Load all aggregates of a given type that are identified by the given ids.- Type Parameters:
T
- the type of the aggregate roots. Must not benull
.- Parameters:
ids
- of the aggregate roots identifying the aggregates to load. Must not benull
.domainType
- the type of the aggregate roots. Must not benull
.- Returns:
- Guaranteed to be not
null
.
-
findAll
Load all aggregates of a given type.- Type Parameters:
T
- the type of the aggregate roots. Must not benull
.- Parameters:
domainType
- the type of the aggregate roots. Must not benull
.- Returns:
- Guaranteed to be not
null
.
-
existsById
Checks if an aggregate identified by type and id exists in the database.- Type Parameters:
T
- the type of the aggregate root.- Parameters:
id
- the id of the aggregate root.domainType
- the type of the aggregate root.- Returns:
- whether the aggregate exists.
-
findAll
Load all aggregates of a given type, sorted.- Type Parameters:
T
- the type of the aggregate roots. Must not benull
.- Parameters:
domainType
- the type of the aggregate roots. Must not benull
.sort
- the sorting information. Must not benull
.- Returns:
- Guaranteed to be not
null
. - Since:
- 2.0
-
findAll
Load a page of (potentially sorted) aggregates of a given type.- Type Parameters:
T
- the type of the aggregate roots. Must not benull
.- Parameters:
domainType
- the type of the aggregate roots. Must not benull
.pageable
- the pagination information. Must not benull
.- Returns:
- Guaranteed to be not
null
. - Since:
- 2.0
-