Polishing.
Fix fragment method order lookup. Lazify ProjectionFactory retrieval on DefaultFragmentCreationContext. See #3265
This commit is contained in:
@@ -25,7 +25,7 @@ import org.springframework.data.repository.aot.generate.json.JSONObject;
|
||||
* @author Mark Paluch
|
||||
* @since 4.0
|
||||
*/
|
||||
record AotRepositoryMetadata(String name, String moduleName,
|
||||
record AotRepositoryMetadata(String name, String module,
|
||||
org.springframework.data.repository.aot.generate.AotRepositoryMetadata.RepositoryType type,
|
||||
List<AotRepositoryMethod> methods) {
|
||||
|
||||
@@ -37,7 +37,7 @@ record AotRepositoryMetadata(String name, String moduleName,
|
||||
|
||||
JSONObject metadata = new JSONObject();
|
||||
metadata.put("name", name());
|
||||
metadata.put("moduleName", moduleName());
|
||||
metadata.put("module", module());
|
||||
metadata.put("type", type().name());
|
||||
|
||||
JSONArray methods = new JSONArray();
|
||||
|
||||
@@ -556,9 +556,9 @@ public class RepositoryComposition {
|
||||
private static @Nullable Method findMethod(InvokedMethod invokedMethod, List<MethodLookup.MethodPredicate> lookups,
|
||||
RepositoryFragments fragments) {
|
||||
|
||||
for (RepositoryFragment<?> fragment : fragments) {
|
||||
for (Method candidate : fragment.findMethods(invokedMethod.getName())) {
|
||||
for (MethodLookup.MethodPredicate methodPredicate : lookups) {
|
||||
for (MethodLookup.MethodPredicate methodPredicate : lookups) {
|
||||
for (RepositoryFragment<?> fragment : fragments) {
|
||||
for (Method candidate : fragment.findMethods(invokedMethod.getName())) {
|
||||
if (methodPredicate.test(invokedMethod, candidate)) {
|
||||
return candidate;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.springframework.data.repository.core.support;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
@@ -373,7 +374,7 @@ public abstract class RepositoryFactoryBeanSupport<T extends Repository<S, ID>,
|
||||
}
|
||||
|
||||
FragmentCreationContext creationContext = new DefaultFragmentCreationContext(repositoryMetadata,
|
||||
valueExpressionDelegate, factory.getProjectionFactory());
|
||||
valueExpressionDelegate, factory::getProjectionFactory);
|
||||
|
||||
RepositoryFragments fragments = RepositoryFragments.empty();
|
||||
for (RepositoryFragmentsFunction function : functions) {
|
||||
@@ -443,7 +444,7 @@ public abstract class RepositoryFactoryBeanSupport<T extends Repository<S, ID>,
|
||||
|
||||
private record DefaultFragmentCreationContext(RepositoryMetadata repositoryMetadata,
|
||||
ValueExpressionDelegate valueExpressionDelegate,
|
||||
ProjectionFactory projectionFactory) implements FragmentCreationContext {
|
||||
Supplier<ProjectionFactory> projectionFactory) implements FragmentCreationContext {
|
||||
|
||||
@Override
|
||||
public RepositoryMetadata getRepositoryMetadata() {
|
||||
@@ -457,7 +458,7 @@ public abstract class RepositoryFactoryBeanSupport<T extends Repository<S, ID>,
|
||||
|
||||
@Override
|
||||
public ProjectionFactory getProjectionFactory() {
|
||||
return projectionFactory();
|
||||
return projectionFactory().get();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user