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:
Oliver Gierke
2018-08-09 12:09:54 +02:00
parent 33a138d30e
commit b80f5c6714

View File

@@ -283,6 +283,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) {