title: Why are Spring Data repository method parameters names not available even on Java 8?
body: <p>I'm having a hard time getting the tests to pass on Pivotal's example project for the <code>spring-boot</code> 1.4 release <a href="https://github.com/spring-projects/spring-data-examples/blob/master/jpa/example/src/main/java/example/springdata/jpa/simple/SimpleUserRepository.java" rel="noreferrer">from their examples</a> which shows <code>spring-data-jpa</code> using <em>unannotated</em> named parameters in its JPQL </p>
  
  <p>e.g. </p>
  
  <blockquote>
    <p>from <a href="https://github.com/spring-projects/spring-data-examples/blob/master/jpa/example/src/main/java/example/springdata/jpa/simple/SimpleUserRepository.java" rel="noreferrer">example.springdata.jpa.simple.SimpleUserRepository</a></p>
  
  <pre><code> @Query("select u from User u where u.firstname = :firstname")
   List&lt;User&gt; findByFirstname(String firstname);
  </code></pre>
  </blockquote>
  
  <p><strong>NB</strong> it is not using the <code>@Param</code> annotation </p>
  
  <p>This doesn't run on my machine. I get the exception detailed here, which is self-explanatory from the title.</p>
  
  <p><a href="https://stackoverflow.com/questions/30788173/name-for-parameter-binding-must-not-be-null-or-empty-for-named-parameters-you-n">Name for parameter binding must not be null or empty! For named parameters you need to use @Param for query method parameters on Java versions</a></p>
  
  <p>So I have to do this instead:</p>
  
  <pre><code>@Query("select u from User u where u.firstname = ?1")
  List&lt;User&gt; findByFirstname(String firstname);
  </code></pre>
  
  <p>or this:</p>
  
  <pre><code>@Query("select u from User u where u.firstname = :firstname")
  List&lt;User&gt; findByFirstname(@Param("firstname") String firstname);
  </code></pre>
  
  <p>What I'm using:</p>
  
  <ul>
  <li>OS - Win7 </li>
  <li>Java - 1.8.0_112</li>
  <li>IDE - Intellij IDEA 2016.2 </li>
  <li>JPA version - JPA v2.0 </li>
  <li>configuration - spring-boot-1.4.1</li>
  </ul>
  
  <p>So have I got something wrong the way I set up the examples? </p>
  
  <p>Did <code>spring-data-jpa</code> include some cool feature at one time to auto-detect param names that for some reason got removed later? </p>
  
  <pre><code>org.springframework.dao.InvalidDataAccessApiUsageException: Name for parameter binding must not be null or empty! For named parameters you need to use @Param for query method parameters on Java versions &lt; 8.; nested exception is java.lang.IllegalArgumentException: Name for parameter binding must not be null or empty! For named parameters you need to use @Param for query method parameters on Java versions &lt; 8.
  
      at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:384)
      at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:246)
      at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:491)
      at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59)
      at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
      at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
      at com.sun.proxy.$Proxy75.findByFirstnameOrLastname(Unknown Source)
  
      at example.springdata.jpa.simple.SimpleUserRepositoryTests.findByFirstnameOrLastname(SimpleUserRepositoryTests.java:86)
        ====================================================================================================================
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:483)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
      at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
      at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
      at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:483)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
  </code></pre>