Java 8 Spring Data JPA Parameter binding

The answer given by @JB Nizet is correct, but I just wanted to point out the way to add the -parameters flag for the Java 8 compiler when using Eclipse. This is in Window -> Preferences:

Preferences setting

Maven also allows adding the flags in the pom itself:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.5.1</version>
    <configuration>
        <compilerArgs>
            <arg>-verbose</arg>
            <arg>-parameters</arg>
        </compilerArgs>
    </configuration>
</plugin>

To add parameters flag for Java 8 compiler when using IDEA IntelliJ

File > Settings > Build, Execution, Deployment > Compiler > Java Compiler

Java Compiler setting


In Java 8, you can use reflection to access names of parameters of methods. This makes the @Param annotation unnecessary, since Spring can deduce the name of the JPQL parameter from the name of the method parameter.

But you need to use the -parameters flag with the compiler to have that information available.

See http://docs.oracle.com/javase/tutorial/reflect/member/methodparameterreflection.html.