DATAJPA-758 - JpaQueryMethod now only checks parameter names if query uses named parameters.

We now only validate parameter names if the declared query actually uses named parameters.

This is mainly needed in context of an (accidentally) mixed use of named parameters with indexed placeholders which can occur if compiling with parameters is activated on Java 8 (i.e. using -parameters) but indexed parameters are used in the query definition.
This commit is contained in:
Oliver Gierke
2015-07-10 18:48:30 +02:00
parent 3a56e003aa
commit e8e8e1b7e2
3 changed files with 27 additions and 1 deletions

View File

@@ -383,6 +383,16 @@ public class JpaQueryMethodUnitTests {
assertThat(method.getEntityGraph().getType(), is(EntityGraphType.FETCH));
}
/**
* @see DATAJPA-758
*/
@Test
public void allowsPositionalBindingEvenIfParametersAreNamed() throws Exception {
new JpaQueryMethod(ValidRepository.class.getMethod("queryWithPositionalBinding", String.class), metadata,
extractor);
}
/**
* Interface to define invalid repository methods for testing.
*
@@ -443,6 +453,9 @@ public class JpaQueryMethodUnitTests {
*/
@EntityGraph(value = "User.propertyLoadPath", type = EntityGraphType.LOAD)
User queryMethodWithCustomEntityFetchGraph(Integer id);
@Query("select u from User u where u.firstname = ?1")
User queryWithPositionalBinding(@Param("firstname") String firstname);
}
static interface JpaRepositoryOverride extends JpaRepository<User, Long> {