Skip to content

Commit cde3404

Browse files
mp911deodrotbohm
authored andcommitted
DATACMNS-939 - Do not create queries for static interface methods.
We now no longer attempt query creation for static methods declared on a repository interface. This allows static method usage inside of repository interfaces. interface PersonRepository extends CrudRepository<Person, String> { static String createId() { // … } default Person findPerson() { return findOne(createId()); } }
1 parent 3cd76d2 commit cde3404

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.io.Serializable;
2323
import java.lang.reflect.GenericDeclaration;
2424
import java.lang.reflect.Method;
25+
import java.lang.reflect.Modifier;
2526
import java.lang.reflect.Type;
2627
import java.lang.reflect.TypeVariable;
2728
import java.util.Collections;
@@ -184,6 +185,7 @@ public Set<Method> getQueryMethods() {
184185
*/
185186
private boolean isQueryMethodCandidate(Method method) {
186187
return !method.isBridge() && !ReflectionUtils.isDefaultMethod(method) //
188+
&& !Modifier.isStatic(method.getModifiers()) //
187189
&& (isQueryAnnotationPresentOn(method) || !isCustomMethod(method) && !isBaseClassMethod(method));
188190
}
189191

0 commit comments

Comments
 (0)