Можно ли использовать пейджинг с пользовательским запросом SQL ebean? Например, когда я настроил этот запрос:
String sql =
"SELECT q.event_id AS event_id,"
+ " MIN(q.total_price) AS price_min, "
+ " MAX(q.total_price) AS price_max "
+ "FROM quote q "
+ "WHERE q.quote_status_id = 2 "
+ " AND q.event_id IS NOT NULL "
+ "GROUP BY q.event_id";
RawSql rawSql = RawSqlBuilder.unparsed(sql)
.columnMapping("event_id", "event.id")
.columnMapping("price_min", "priceMin")
.columnMapping("price_max", "priceMax")
.create();
com.avaje.ebean.Query<salesPipelineRow> ebeanQuery = Ebean.find(salesPipelineRow.class);
ebeanQuery.setRawSql(rawSql);
...Тогда я могу позвонить...
List<salesPipelineRow> list = ebeanQuery.findList();
... без каких-либо проблем (т.е. я получаю действительный список объектов salesPipelineRow). Однако, когда я вместо этого пытаюсь что-то вроде...
Page<salesPipelineRow> page = ebeanQuery.findPagingList(5).getPage(0);
... Я получаю нулевую ошибку, например:
java.util.concurrent.ExecutionException: javax.persistence.PersistenceException:
Query threw SQLException:You have an error in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near 'null t0
limit 6' at line 2
Bind values:[]
Query was:
select t0.price_min c0, t0.price_max c1, t0.event_id c2
from null t0
limit 6
Кто-нибудь может объяснить, почему предложения FROM, WHERE и GROUP BY заменяются на «null»?
Спасибо!