カスタム 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);
...次のような null エラーが発生します。
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」に置き換えられる理由を誰か説明できますか?
ありがとう!