34
34
* @author Tom Hombergs
35
35
* @author David Madden
36
36
* @author Mark Paluch
37
+ * @author Diego Krupitza
37
38
*/
38
39
abstract class AbstractStringBasedJpaQuery extends AbstractJpaQuery {
39
40
@@ -55,8 +56,8 @@ abstract class AbstractStringBasedJpaQuery extends AbstractJpaQuery {
55
56
* @param parser must not be {@literal null}.
56
57
*/
57
58
public AbstractStringBasedJpaQuery (JpaQueryMethod method , EntityManager em , String queryString ,
58
- @ Nullable String countQueryString ,
59
- QueryMethodEvaluationContextProvider evaluationContextProvider , SpelExpressionParser parser ) {
59
+ @ Nullable String countQueryString , QueryMethodEvaluationContextProvider evaluationContextProvider ,
60
+ SpelExpressionParser parser ) {
60
61
61
62
super (method , em );
62
63
@@ -65,10 +66,12 @@ public AbstractStringBasedJpaQuery(JpaQueryMethod method, EntityManager em, Stri
65
66
Assert .notNull (parser , "Parser must not be null!" );
66
67
67
68
this .evaluationContextProvider = evaluationContextProvider ;
68
- this .query = new ExpressionBasedStringQuery (queryString , method .getEntityInformation (), parser );
69
+ this .query = new ExpressionBasedStringQuery (queryString , method .getEntityInformation (), parser ,
70
+ method .isNativeQuery ());
69
71
70
72
DeclaredQuery countQuery = query .deriveCountQuery (countQueryString , method .getCountQueryProjection ());
71
- this .countQuery = ExpressionBasedStringQuery .from (countQuery , method .getEntityInformation (), parser );
73
+ this .countQuery = ExpressionBasedStringQuery .from (countQuery , method .getEntityInformation (), parser ,
74
+ method .isNativeQuery ());
72
75
73
76
this .parser = parser ;
74
77
@@ -79,7 +82,8 @@ public AbstractStringBasedJpaQuery(JpaQueryMethod method, EntityManager em, Stri
79
82
@ Override
80
83
public Query doCreateQuery (JpaParametersParameterAccessor accessor ) {
81
84
82
- String sortedQueryString = QueryUtils .applySorting (query .getQueryString (), accessor .getSort (), query .getAlias ());
85
+ String sortedQueryString = QueryEnhancerFactory .forQuery (query ) //
86
+ .applySorting (accessor .getSort (), query .getAlias ());
83
87
ResultProcessor processor = getQueryMethod ().getResultProcessor ().withDynamicProjection (accessor );
84
88
85
89
Query query = createJpaQuery (sortedQueryString , processor .getReturnedType ());
0 commit comments