是否可以在自定义SQL查询中使用分页?例如,当我设置此查询时:
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可以打电话给..。
List<salesPipelineRow> list = ebeanQuery.findList();...without任何问题(例如,我得到一个有效的salesPipelineRow对象列表)。然而,当我试着做这样的事情时.
Page<salesPipelineRow> page = ebeanQuery.findPagingList(5).getPage(0);...I获得一个空错误,如:
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“替换吗?
谢谢!
发布于 2013-10-27 10:22:44
我想这必须在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 6https://stackoverflow.com/questions/15348744
复制相似问题