Я пытаюсь создать собственный запрос, который поддерживает разбиение на страницы для представлений весной jpa.Но, похоже, ORDER BY вызывает некоторые проблемы с представлением.Пожалуйста, помогите мне решить эту проблему
@Query(nativeQuery = true, value = "SELECT mvno_id , tac, imsi, manufacturer, model_name, is_active, created_time, last_modified_time FROM "
+ "(SELECT A.mvno_id mvno_id, B.tac tac, A.imsi imsi, B.manufacturer manufacturer , B.model_name model_name, "
+ "A.is_active is_active, A.created_time created_time, A.last_modified_time last_modified_time"
+ " FROM device_repo.device_info A "
+ "INNER JOIN device_repo.device_pack B ON A.imei = B.tac and B.model_name = ?1) "
+ "device_view ORDER BY ?#{#pageable}",
countQuery = "SELECT count(*) FROM device_view")
public Page<DevicePackEntityView> findByModelName(String model, Pageable pageable);
Но я получил исключение ниже
org.postgresql.util.PSQLException: ERROR: missing FROM-clause entry for table "a"
Position: 448
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2455) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2155) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:288) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:430) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
Динамически сформированный SQL-запрос
SELECT
mvno_id ,
tac,
imsi,
manufacturer,
model_name,
is_active,
created_time,
last_modified_time
FROM
(SELECT
A.mvno_id mvno_id,
B.tac tac,
A.imsi imsi,
B.manufacturer manufacturer ,
B.model_name model_name,
A.is_active is_active,
A.created_time created_time,
A.last_modified_time last_modified_time
FROM
device_repo.device_info A
INNER JOIN
device_repo.device_pack B
ON A.imei = B.tac
and B.model_name = ?) device_view
ORDER BY
?,
A.manufacturer asc limit ?