@@ -149,7 +149,9 @@ public DeclaredQueryLookupStrategy(EntityManager em, JpaQueryMethodFactory query
149149 @ Override
150150 protected RepositoryQuery resolveQuery (JpaQueryMethod method , EntityManager em , NamedQueries namedQueries ) {
151151
152- String countQuery = getCountQuery (method , namedQueries , em );
152+ if (method .isProcedureQuery ()) {
153+ return JpaQueryFactory .INSTANCE .fromProcedureAnnotation (method , em );
154+ }
153155
154156 if (StringUtils .hasText (method .getAnnotatedQuery ())) {
155157
@@ -158,23 +160,18 @@ protected RepositoryQuery resolveQuery(JpaQueryMethod method, EntityManager em,
158160 "Query method %s is annotated with both, a query and a query name. Using the declared query." , method ));
159161 }
160162
161- return JpaQueryFactory .INSTANCE .fromMethodWithQueryString (method , em , method .getAnnotatedQuery (), countQuery ,
163+ return JpaQueryFactory .INSTANCE .fromMethodWithQueryString (method , em , method .getRequiredAnnotatedQuery (),
164+ getCountQuery (method , namedQueries , em ),
162165 evaluationContextProvider );
163166 }
164167
165- RepositoryQuery query = JpaQueryFactory .INSTANCE .fromProcedureAnnotation (method , em );
166-
167- if (null != query ) {
168- return query ;
169- }
170-
171168 String name = method .getNamedQueryName ();
172169 if (namedQueries .hasQuery (name )) {
173- return JpaQueryFactory .INSTANCE .fromMethodWithQueryString (method , em , namedQueries .getQuery (name ), countQuery ,
170+ return JpaQueryFactory .INSTANCE .fromMethodWithQueryString (method , em , namedQueries .getQuery (name ), getCountQuery ( method , namedQueries , em ) ,
174171 evaluationContextProvider );
175172 }
176173
177- query = NamedQuery .lookupFrom (method , em );
174+ RepositoryQuery query = NamedQuery .lookupFrom (method , em );
178175
179176 if (null != query ) {
180177 return query ;
0 commit comments