我需要使用带有多个字段的带有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"))));
非常感谢提前!
答案 0 :(得分:3)
您可以这样做:
ProjectionList projectionList = ProjectionFactoryUtil.projectionList();
projectionList.add(projection1);
projectionList.add(projection2);
dynamicQuery.setProjection(projectionList);