我有一個涉及標題和說明的簡單模型。它擴展play.db.jpa.Model爲什麼我的Play Framework(1.2.4)計數查詢失敗?
下面的搜索方法,完美的作品
public static SearchResults search(String search, Integer page) {
String likeSearch = "%" + search + "%";
long count = find("title like ? OR description like ? order by " +
"title ASC", likeSearch, likeSearch).fetch().size();
List<Must> items = find("title like ? OR description like ? order by " +
"title ASC", likeSearch, likeSearch).fetch(page, 20);
return new SearchResults(items, count);
}
然而,當我調整數如下
long count = count("title like ? OR description like ? order by " +
"title ASC", likeSearch, likeSearch);
我得到
PersistenceException occured : org.hibernate.exception.SQLGrammarException: could not execute query
ERROR ~ ERROR: column "must0_.title" must appear in the GROUP BY clause or be used in an aggregate function
爲什麼當查詢完全沒有改變時,是否要求我使用聚合函數?