AGGREGATE - the aggregate root typeKEY - the key typepublic abstract class BaseRepository<AGGREGATE extends AggregateRoot<KEY>,KEY> extends Object implements Repository<AGGREGATE,KEY>
| Modifier and Type | Field and Description |
|---|---|
protected Class<AGGREGATE> |
aggregateRootClass |
protected Class<KEY> |
keyClass |
| Modifier | Constructor and Description |
|---|---|
protected |
BaseRepository()
Constructs a base repository.
|
protected |
BaseRepository(Class<AGGREGATE> aggregateRootClass,
Class<KEY> keyClass)
Constructs a base repository settings explicitly the aggregate root class and the key class.
|
| Modifier and Type | Method and Description |
|---|---|
void |
delete(AGGREGATE aggregate)
Deletes an aggregate instance from the persistence.
|
void |
delete(KEY id)
Deletes an aggregate from the persistence by its key.
|
protected abstract void |
doDelete(AGGREGATE aggregate)
Delegates the delete mechanism to the infrastructure.
|
protected abstract void |
doDelete(KEY id)
Delegates the delete mechanism to the infrastructure.
|
protected abstract AGGREGATE |
doLoad(KEY id)
Delegates the load mechanism to the infrastructure.
|
protected abstract void |
doPersist(AGGREGATE aggregate)
Delegates the persist mechanism to the infrastructure.
|
protected abstract AGGREGATE |
doSave(AGGREGATE aggregate)
Delegates the save mechanism to the infrastructure.
|
Class<AGGREGATE> |
getAggregateRootClass() |
Class<KEY> |
getKeyClass() |
AGGREGATE |
load(KEY id)
Loads an aggregate from the persistence by its key.
|
void |
persist(AGGREGATE aggregate)
Creates an aggregate in the persistence.
|
AGGREGATE |
save(AGGREGATE aggregate)
Updates an aggregate in the persistence
|
protected Class<AGGREGATE extends AggregateRoot<KEY>> aggregateRootClass
protected BaseRepository()
The aggregate root class and the key class are found by reflection.
protected BaseRepository(Class<AGGREGATE> aggregateRootClass, Class<KEY> keyClass)
This is use when the implementation class does not resolve the generics. Since the generic types can't be resolve at runtime, they should be passed explicitly.
aggregateRootClass - the aggregate root classkeyClass - the key classpublic Class<AGGREGATE> getAggregateRootClass()
getAggregateRootClass in interface Repository<AGGREGATE extends AggregateRoot<KEY>,KEY>public Class<KEY> getKeyClass()
getKeyClass in interface Repository<AGGREGATE extends AggregateRoot<KEY>,KEY>public final AGGREGATE load(KEY id)
Repositoryload in interface Repository<AGGREGATE extends AggregateRoot<KEY>,KEY>id - the aggregate keypublic final void delete(KEY id)
Repositorydelete in interface Repository<AGGREGATE extends AggregateRoot<KEY>,KEY>id - the aggregate keypublic final void delete(AGGREGATE aggregate)
Repositorydelete in interface Repository<AGGREGATE extends AggregateRoot<KEY>,KEY>aggregate - the aggregate to deletepublic final void persist(AGGREGATE aggregate)
Repositorypersist in interface Repository<AGGREGATE extends AggregateRoot<KEY>,KEY>aggregate - the aggregate to persistpublic final AGGREGATE save(AGGREGATE aggregate)
Repositorysave in interface Repository<AGGREGATE extends AggregateRoot<KEY>,KEY>aggregate - the aggregate to save@Read protected abstract AGGREGATE doLoad(KEY id)
id - the identifier of the aggregate root to load@Delete protected abstract void doDelete(KEY id)
id - the identifier of the aggregate root to delete@Delete protected abstract void doDelete(AGGREGATE aggregate)
aggregate - the aggregate to delete@Persist protected abstract void doPersist(AGGREGATE aggregate)
aggregate - the aggregate to persistCopyright © 2013-2016–2016 SeedStack. All rights reserved.