Skip to content

Commit b80f5c6

Browse files
committed
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.
1 parent 33a138d commit b80f5c6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Diff for: src/main/java/org/springframework/data/repository/core/support/RepositoryFactoryBeanSupport.java

+4
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,10 @@ public void afterPropertiesSet() {
283283
.append(customImplementationFragment);
284284

285285
this.repositoryMetadata = this.factory.getRepositoryMetadata(repositoryInterface);
286+
287+
// Make sure the aggregate root type is present in the MappingContext (e.g. for auditing)
288+
this.mappingContext.ifPresent(it -> it.getPersistentEntity(repositoryMetadata.getDomainType()));
289+
286290
this.repository = Lazy.of(() -> this.factory.getRepository(repositoryInterface, repositoryFragmentsToUse));
287291

288292
if (!lazyInit) {

0 commit comments

Comments
 (0)