【发布时间】:2016-04-08 20:13:04
【问题描述】:
我的实体看起来像:
class News {
private Long id;
private Author author;
private List<Tag> tagsList;
private String title;
private List<Comment> commentsList;
private Date modificationDate;
}
1) 我想按属性大小和日期排序结果列表。
我的代码部分:
cq.select(from).distinct(true)
.orderBy(cb.desc(from.get("commentsList.size")), cb.desc(from.get("modificationDate")));
当然“.size”是错的。我如何使用标准 API 来做到这一点?
2) 如何在标准中添加tagsList 和Author 中的Tags?
【问题讨论】:
-
集合的大小是通过 CriteriaBuilder.size(...) 完成的,参数是“from.get("cmetsList")”。试过了吗?
标签: java jpa eclipselink criteria criteria-api