Browse Source

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.
pull/300/merge
Oliver Gierke 8 years ago
parent
commit
084b46036a
No known key found for this signature in database
GPG Key ID: 6E42B5787543F690
  1. 4
      src/main/java/org/springframework/data/repository/core/support/RepositoryFactoryBeanSupport.java

4
src/main/java/org/springframework/data/repository/core/support/RepositoryFactoryBeanSupport.java

@ -290,6 +290,10 @@ public abstract class RepositoryFactoryBeanSupport<T extends Repository<S, ID>, @@ -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) {

Loading…
Cancel
Save