1
1
/*
2
- * Copyright 2013-2014 the original author or authors.
2
+ * Copyright 2013-2015 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
32
32
import org .springframework .data .repository .core .RepositoryMetadata ;
33
33
import org .springframework .data .repository .query .Param ;
34
34
import org .springframework .util .Assert ;
35
+ import org .springframework .util .ClassUtils ;
35
36
import org .springframework .util .LinkedMultiValueMap ;
36
37
import org .springframework .util .MultiValueMap ;
37
38
import org .springframework .util .ReflectionUtils ;
46
47
class ReflectionRepositoryInvoker implements RepositoryInvoker {
47
48
48
49
private static final AnnotationAttribute PARAM_ANNOTATION = new AnnotationAttribute (Param .class );
50
+ private static final String NAME_NOT_FOUND = "Unable to detect parameter names for query method %s! Use @Param or compile with -parameters on JDK 8." ;
49
51
50
52
private final Object repository ;
51
53
private final CrudMethods methods ;
@@ -60,7 +62,8 @@ class ReflectionRepositoryInvoker implements RepositoryInvoker {
60
62
* @param metadata must not be {@literal null}.
61
63
* @param conversionService must not be {@literal null}.
62
64
*/
63
- public ReflectionRepositoryInvoker (Object repository , RepositoryMetadata metadata , ConversionService conversionService ) {
65
+ public ReflectionRepositoryInvoker (Object repository , RepositoryMetadata metadata ,
66
+ ConversionService conversionService ) {
64
67
65
68
Assert .notNull (repository , "Repository must not be null!" );
66
69
Assert .notNull (metadata , "RepositoryMetadata must not be null!" );
@@ -229,8 +232,7 @@ private Object[] prepareParameters(Method method, MultiValueMap<String, ? extend
229
232
String parameterName = param .getParameterName ();
230
233
231
234
if (!StringUtils .hasText (parameterName )) {
232
- throw new IllegalArgumentException ("No @Param annotation found on query method " + method .getName ()
233
- + " for parameter " + parameterName );
235
+ throw new IllegalArgumentException (String .format (NAME_NOT_FOUND , ClassUtils .getQualifiedMethodName (method )));
234
236
}
235
237
236
238
Object value = unwrapSingleElement (rawParameters .get (parameterName ));
0 commit comments