Skip to content

Commit

Permalink
DATACMNS-939 - Do not create queries for static interface methods.
Browse files Browse the repository at this point in the history
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());
    }
}
  • Loading branch information
mp911de authored and odrotbohm committed Nov 21, 2016
1 parent 3cd76d2 commit cde3404
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.io.Serializable;
import java.lang.reflect.GenericDeclaration;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.util.Collections;
Expand Down Expand Up @@ -184,6 +185,7 @@ public Set<Method> getQueryMethods() {
*/
private boolean isQueryMethodCandidate(Method method) {
return !method.isBridge() && !ReflectionUtils.isDefaultMethod(method) //
&& !Modifier.isStatic(method.getModifiers()) //
&& (isQueryAnnotationPresentOn(method) || !isCustomMethod(method) && !isBaseClassMethod(method));
}

Expand Down

0 comments on commit cde3404

Please sign in to comment.