@@ -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
@@ -293,19 +293,19 @@ void resolvesExpressionInCountQuery() throws Exception {
293
293
}
294
294
295
295
private AbstractJpaQuery createJpaQuery (Method method ) {
296
- return createJpaQuery (method , null );
296
+ return createJpaQuery (method , Optional . empty () );
297
297
}
298
298
299
- private AbstractJpaQuery createJpaQuery (JpaQueryMethod queryMethod , @ Nullable String queryString , @ Nullable String countQueryString ) {
299
+ private AbstractJpaQuery createJpaQuery (JpaQueryMethod queryMethod , String queryString , @ Nullable String countQueryString ) {
300
300
301
301
return JpaQueryFactory .INSTANCE .fromMethodWithQueryString (queryMethod , em , queryString , countQueryString ,
302
302
QueryRewriter .IdentityQueryRewriter .INSTANCE , ValueExpressionDelegate .create ());
303
303
}
304
304
305
- private AbstractJpaQuery createJpaQuery (Method method , @ Nullable Optional <String > countQueryString ) {
305
+ private AbstractJpaQuery createJpaQuery (Method method , Optional <String > countQueryString ) {
306
306
307
307
JpaQueryMethod queryMethod = new JpaQueryMethod (method , metadata , factory , extractor );
308
- return createJpaQuery (queryMethod , queryMethod .getAnnotatedQuery (), countQueryString == null ? null : countQueryString .orElse (queryMethod .getCountQuery ()));
308
+ return createJpaQuery (queryMethod , queryMethod .getAnnotatedQuery (), countQueryString .orElse (queryMethod .getCountQuery ()));
309
309
}
310
310
311
311
interface SampleRepository {
0 commit comments