Skip to content

Commit 084b460

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 1984fbd commit 084b460

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
@@ -290,6 +290,10 @@ public void afterPropertiesSet() {
290290
.append(customImplementationFragment);
291291

292292
this.repositoryMetadata = this.factory.getRepositoryMetadata(repositoryInterface);
293+
294+
// Make sure the aggregate root type is present in the MappingContext (e.g. for auditing)
295+
this.mappingContext.ifPresent(it -> it.getPersistentEntity(repositoryMetadata.getDomainType()));
296+
293297
this.repository = Lazy.of(() -> this.factory.getRepository(repositoryInterface, repositoryFragmentsToUse));
294298

295299
if (!lazyInit) {

0 commit comments

Comments
 (0)