我在liferay中有关于动态查询的简单问题。 如何在动态查询中使用group by
例如:选择date_,count(*)来自按日期剪切组_;
如何在liferay动态查询中执行此操作?
请帮忙
由于
答案 0 :(得分:2)
试试这个:
DynamicQuery dynamicQuery = ClippingLocalServiceUtil.dynamicQuery();
ProjectionList projectionList = ProjectionFactoryUtil.projectionList();
projectionList.add(ProjectionFactoryUtil.groupProperty("date"));
projectionList.add(ProjectionFactoryUtil.rowCount());
dynamicQuery.setProjection(projectionList);
List<Object[]> results = ClippingLocalServiceUtil.dynamicQuery(dynamicQuery);