2

カスタム 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」に置き換えられる理由を誰か説明できますか?

ありがとう!

4

1 に答える 1

0

これは、EBean メーリング リストを介して実行する必要があると思います (まだアクティブな場合。EBean は完全に死んでいると思います)。私にはバグのように見えます。レンダリングする必要があるSQL は次のようになります。

select t0.price_min c0, t0.price_max c1, t0.event_id c2
from (
    SELECT [... your raw SQL statement here ...]
) t0
limit 6
于 2013-10-27T10:22:44.027 に答える