是否可以将分页与自定义 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”取代?
谢谢!