Skip to content

Commit 47b8658

Browse files
mp911deschauder
authored andcommitted
Polishing.
Fix fragment method order lookup. Lazify ProjectionFactory retrieval on DefaultFragmentCreationContext. See #3265
1 parent 9706655 commit 47b8658

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

Diff for: src/main/java/org/springframework/data/repository/aot/generate/AotRepositoryMetadata.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* @author Mark Paluch
2626
* @since 4.0
2727
*/
28-
record AotRepositoryMetadata(String name, String moduleName,
28+
record AotRepositoryMetadata(String name, String module,
2929
org.springframework.data.repository.aot.generate.AotRepositoryMetadata.RepositoryType type,
3030
List<AotRepositoryMethod> methods) {
3131

@@ -37,7 +37,7 @@ JSONObject toJson() throws JSONException {
3737

3838
JSONObject metadata = new JSONObject();
3939
metadata.put("name", name());
40-
metadata.put("moduleName", moduleName());
40+
metadata.put("module", module());
4141
metadata.put("type", type().name());
4242

4343
JSONArray methods = new JSONArray();

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,9 @@ private RepositoryFragment<?> findImplementationFragment(Method key) {
556556
private static @Nullable Method findMethod(InvokedMethod invokedMethod, List<MethodLookup.MethodPredicate> lookups,
557557
RepositoryFragments fragments) {
558558

559-
for (RepositoryFragment<?> fragment : fragments) {
560-
for (Method candidate : fragment.findMethods(invokedMethod.getName())) {
561-
for (MethodLookup.MethodPredicate methodPredicate : lookups) {
559+
for (MethodLookup.MethodPredicate methodPredicate : lookups) {
560+
for (RepositoryFragment<?> fragment : fragments) {
561+
for (Method candidate : fragment.findMethods(invokedMethod.getName())) {
562562
if (methodPredicate.test(invokedMethod, candidate)) {
563563
return candidate;
564564
}

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.util.ArrayList;
1919
import java.util.List;
20+
import java.util.function.Supplier;
2021

2122
import org.jspecify.annotations.NonNull;
2223
import org.jspecify.annotations.Nullable;
@@ -373,7 +374,7 @@ private RepositoryFragments getRepositoryFragments(RepositoryMetadata repository
373374
}
374375

375376
FragmentCreationContext creationContext = new DefaultFragmentCreationContext(repositoryMetadata,
376-
valueExpressionDelegate, factory.getProjectionFactory());
377+
valueExpressionDelegate, factory::getProjectionFactory);
377378

378379
RepositoryFragments fragments = RepositoryFragments.empty();
379380
for (RepositoryFragmentsFunction function : functions) {
@@ -443,7 +444,7 @@ public interface FragmentCreationContext {
443444

444445
private record DefaultFragmentCreationContext(RepositoryMetadata repositoryMetadata,
445446
ValueExpressionDelegate valueExpressionDelegate,
446-
ProjectionFactory projectionFactory) implements FragmentCreationContext {
447+
Supplier<ProjectionFactory> projectionFactory) implements FragmentCreationContext {
447448

448449
@Override
449450
public RepositoryMetadata getRepositoryMetadata() {
@@ -457,7 +458,7 @@ public ValueExpressionDelegate getValueExpressionDelegate() {
457458

458459
@Override
459460
public ProjectionFactory getProjectionFactory() {
460-
return projectionFactory();
461+
return projectionFactory().get();
461462
}
462463

463464
}

0 commit comments

Comments
 (0)