DATACMNS-1369 - RepositoryFactoryBeanSupport now adds the aggregate root type to the MappingContext.
We now eagerly look up the aggregate root type of a repository in the MappingContext. Some implementations might not have pre-populated the context with all entities and we need to make sure it knows about the aggregate root as other clients (e.g. the auditing subsystem) might only defensively access the entities via PersistentEntities which is not adding new entities to avoid store clashes.
This commit is contained in:
@@ -290,6 +290,10 @@ public abstract class RepositoryFactoryBeanSupport<T extends Repository<S, ID>,
|
||||
.append(customImplementationFragment);
|
||||
|
||||
this.repositoryMetadata = this.factory.getRepositoryMetadata(repositoryInterface);
|
||||
|
||||
// Make sure the aggregate root type is present in the MappingContext (e.g. for auditing)
|
||||
this.mappingContext.ifPresent(it -> it.getPersistentEntity(repositoryMetadata.getDomainType()));
|
||||
|
||||
this.repository = Lazy.of(() -> this.factory.getRepository(repositoryInterface, repositoryFragmentsToUse));
|
||||
|
||||
if (!lazyInit) {
|
||||
|
||||
Reference in New Issue
Block a user