Liferay动态查询投影有两个字段

时间:2014-09-28 08:45:45

标签: liferay liferay-6 dynamicquery

我需要使用带有多个字段的带有Projection的动态查询。像这样的东西

DynamicQuery query = DynamicQueryFactoryUtil.forClass(Purchase.class);      query.add(PropertyFactoryUtil.forName("primaryKey.purchaseId,primaryKey.otherId").in(DynamicQueryFactoryUtil.forClass(ResponseField.class)          
                .add(PropertyFactoryUtil.forName("something").eq("something"))
                .setProjection(ProjectionFactoryUtil.property("primaryKey.purchaseId,primaryKey.otherId"))));

非常感谢提前!

1 个答案:

答案 0 :(得分:3)

您可以这样做:

ProjectionList projectionList = ProjectionFactoryUtil.projectionList();

projectionList.add(projection1);
projectionList.add(projection2);

dynamicQuery.setProjection(projectionList);