@@ -111,7 +111,7 @@ void prefersDeclaredCountQueryOverCreatingOne() throws Exception {
111
111
metadata , factory , extractor );
112
112
when (em .createQuery ("foo" , Long .class )).thenReturn (typedQuery );
113
113
114
- SimpleJpaQuery jpaQuery = new SimpleJpaQuery (method , em , "select u from User u" , EVALUATION_CONTEXT_PROVIDER ,
114
+ SimpleJpaQuery jpaQuery = new SimpleJpaQuery (method , em , "select u from User u" , null , EVALUATION_CONTEXT_PROVIDER ,
115
115
PARSER );
116
116
117
117
assertThat (jpaQuery .createCountQuery (new JpaParametersParameterAccessor (method .getParameters (), new Object [] {})))
@@ -126,7 +126,8 @@ void doesNotApplyPaginationToCountQuery() throws Exception {
126
126
Method method = UserRepository .class .getMethod ("findAllPaged" , Pageable .class );
127
127
JpaQueryMethod queryMethod = new JpaQueryMethod (method , metadata , factory , extractor );
128
128
129
- AbstractJpaQuery jpaQuery = new SimpleJpaQuery (queryMethod , em , "select u from User u" , EVALUATION_CONTEXT_PROVIDER ,
129
+ AbstractJpaQuery jpaQuery = new SimpleJpaQuery (queryMethod , em , "select u from User u" , null ,
130
+ EVALUATION_CONTEXT_PROVIDER ,
130
131
PARSER );
131
132
jpaQuery .createCountQuery (
132
133
new JpaParametersParameterAccessor (queryMethod .getParameters (), new Object [] { PageRequest .of (1 , 10 ) }));
@@ -141,8 +142,8 @@ void discoversNativeQuery() throws Exception {
141
142
142
143
Method method = SampleRepository .class .getMethod ("findNativeByLastname" , String .class );
143
144
JpaQueryMethod queryMethod = new JpaQueryMethod (method , metadata , factory , extractor );
144
- AbstractJpaQuery jpaQuery = JpaQueryFactory .INSTANCE .fromQueryAnnotation (queryMethod , em ,
145
- EVALUATION_CONTEXT_PROVIDER );
145
+ AbstractJpaQuery jpaQuery = JpaQueryFactory .INSTANCE .fromMethodWithQueryString (queryMethod , em ,
146
+ queryMethod . getAnnotatedQuery (), null , EVALUATION_CONTEXT_PROVIDER );
146
147
147
148
assertThat (jpaQuery instanceof NativeJpaQuery ).isTrue ();
148
149
@@ -244,7 +245,8 @@ void resolvesExpressionInCountQuery() throws Exception {
244
245
Method method = SampleRepository .class .getMethod ("findAllWithExpressionInCountQuery" , Pageable .class );
245
246
JpaQueryMethod queryMethod = new JpaQueryMethod (method , metadata , factory , extractor );
246
247
247
- AbstractJpaQuery jpaQuery = new SimpleJpaQuery (queryMethod , em , "select u from User u" , EVALUATION_CONTEXT_PROVIDER ,
248
+ AbstractJpaQuery jpaQuery = new SimpleJpaQuery (queryMethod , em , "select u from User u" ,
249
+ "select count(u.id) from #{#entityName} u" , EVALUATION_CONTEXT_PROVIDER ,
248
250
PARSER );
249
251
jpaQuery .createCountQuery (
250
252
new JpaParametersParameterAccessor (queryMethod .getParameters (), new Object [] { PageRequest .of (1 , 10 ) }));
@@ -256,7 +258,8 @@ void resolvesExpressionInCountQuery() throws Exception {
256
258
private AbstractJpaQuery createJpaQuery (Method method ) {
257
259
258
260
JpaQueryMethod queryMethod = new JpaQueryMethod (method , metadata , factory , extractor );
259
- return JpaQueryFactory .INSTANCE .fromQueryAnnotation (queryMethod , em , EVALUATION_CONTEXT_PROVIDER );
261
+ return JpaQueryFactory .INSTANCE .fromMethodWithQueryString (queryMethod , em , queryMethod .getAnnotatedQuery (), null ,
262
+ EVALUATION_CONTEXT_PROVIDER );
260
263
}
261
264
262
265
interface SampleRepository {
0 commit comments