this.method = method;
this.query = new StringQuery(queryString);
this.countQuery = new StringQuery(method.getCountQuery() == null ? QueryUtils.createCountQueryFor(queryString)
: method.getCountQuery());
Parameters parameters = method.getParameters();
boolean hasPagingOrSortingParameter = parameters.hasPageableParameter() || parameters.hasSortParameter();
if (method.isNativeQuery() && hasPagingOrSortingParameter) {
throw new IllegalStateException("Cannot use native queries with dynamic sorting and/or pagination!");
}