From 4eb00535caa2f7a6d7fd941bdcb567b683dde4f8 Mon Sep 17 00:00:00 2001 From: "petar.tahchiev" Date: Sat, 24 Jun 2023 23:22:47 +0300 Subject: [PATCH] Use Repositories to populate cache instead of PersistentEntities If we use PersistentEntities to populate the cache, then it completely disregards the alternative domain types of the reposiory. --- .../rest/core/mapping/RepositoryResourceMappings.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/RepositoryResourceMappings.java b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/RepositoryResourceMappings.java index b71461a11..60de8e905 100644 --- a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/RepositoryResourceMappings.java +++ b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/RepositoryResourceMappings.java @@ -61,14 +61,12 @@ public RepositoryResourceMappings(Repositories repositories, PersistentEntities this.repositories = repositories; this.configuration = configuration; - this.populateCache(entities, configuration); + this.populateCache(repositories, configuration); } - private void populateCache(PersistentEntities entities, RepositoryRestConfiguration configuration) { + private void populateCache(Repositories repositories, RepositoryRestConfiguration configuration) { - for (PersistentEntity> entity : entities) { - - Class type = entity.getType(); + for (Class type : repositories) { if (!repositories.hasRepositoryFor(type)) { continue; @@ -76,6 +74,7 @@ private void populateCache(PersistentEntities entities, RepositoryRestConfigurat RepositoryInformation repositoryInformation = repositories.getRequiredRepositoryInformation(type); Class repositoryInterface = repositoryInformation.getRepositoryInterface(); + PersistentEntity entity = repositories.getPersistentEntity(type); RepositoryDetectionStrategy strategy = configuration.getRepositoryDetectionStrategy(); LinkRelationProvider provider = configuration.getLinkRelationProvider();