@@ -192,7 +192,7 @@ void doesNotValidateCountQueryIfNotPagingMethod() throws Exception {
192
192
createJpaQuery (method );
193
193
}
194
194
195
- @ Test // DATAJPA-352
195
+ @ Test // DATAJPA-352, GH-2736
196
196
void validatesAndRejectsCountQueryIfPagingMethod () throws Exception {
197
197
198
198
Method method = SampleRepository .class .getMethod ("pageByAnnotatedQuery" , Pageable .class );
@@ -201,7 +201,7 @@ void validatesAndRejectsCountQueryIfPagingMethod() throws Exception {
201
201
202
202
assertThatIllegalArgumentException () //
203
203
.isThrownBy (() -> createJpaQuery (method )) //
204
- .withMessageContaining ("Count " ) //
204
+ .withMessageContaining ("User u " ) //
205
205
.withMessageContaining (method .getName ());
206
206
}
207
207
@@ -356,21 +356,21 @@ void resolvesExpressionInCountQuery() throws Exception {
356
356
}
357
357
358
358
private AbstractJpaQuery createJpaQuery (Method method ) {
359
- return createJpaQuery (method , null );
359
+ return createJpaQuery (method , Optional . empty () );
360
360
}
361
361
362
- private AbstractJpaQuery createJpaQuery (JpaQueryMethod queryMethod , @ Nullable String queryString ,
362
+ private AbstractJpaQuery createJpaQuery (JpaQueryMethod queryMethod , String queryString ,
363
363
@ Nullable String countQueryString ) {
364
364
365
365
return JpaQueryFactory .INSTANCE .fromMethodWithQueryString (queryMethod , em , queryString , countQueryString ,
366
366
QueryRewriter .IdentityQueryRewriter .INSTANCE , ValueExpressionDelegate .create ());
367
367
}
368
368
369
- private AbstractJpaQuery createJpaQuery (Method method , @ Nullable Optional <String > countQueryString ) {
369
+ private AbstractJpaQuery createJpaQuery (Method method , Optional <String > countQueryString ) {
370
370
371
371
JpaQueryMethod queryMethod = new JpaQueryMethod (method , metadata , factory , extractor );
372
372
return createJpaQuery (queryMethod , queryMethod .getAnnotatedQuery (),
373
- countQueryString == null ? null : countQueryString .orElse (queryMethod .getCountQuery ()));
373
+ countQueryString .orElse (queryMethod .getCountQuery ()));
374
374
}
375
375
376
376
private String createQuery (AbstractStringBasedJpaQuery jpaQuery ) {
0 commit comments