首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >播放框架ebean RawSql分页

播放框架ebean RawSql分页
EN

Stack Overflow用户
提问于 2013-03-11 21:12:29
回答 1查看 2.1K关注 0票数 2

是否可以在自定义SQL查询中使用分页?例如,当我设置此查询时:

代码语言:javascript
复制
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);

然后...I可以打电话给..。

代码语言:javascript
复制
List<salesPipelineRow> list = ebeanQuery.findList();

...without任何问题(例如,我得到一个有效的salesPipelineRow对象列表)。然而,当我试着做这样的事情时.

代码语言:javascript
复制
Page<salesPipelineRow> page = ebeanQuery.findPagingList(5).getPage(0);

...I获得一个空错误,如:

代码语言:javascript
复制
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“替换吗?

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2013-10-27 10:22:44

我想这必须在EBean邮件列表中运行(如果它仍然处于活动状态)。我认为EBean已经死了)。在我看来是个虫子。应该呈现的SQL是:

代码语言:javascript
复制
select t0.price_min c0, t0.price_max c1, t0.event_id c2
from (
    SELECT [... your raw SQL statement here ...]
) t0
limit 6
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15348744

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档