Reputation: 85
I need to use a Dynamic Query with Projection with several fields. Something like that
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"))));
Many thanks in advance!
Upvotes: 1
Views: 2344
Reputation: 967
You can do something like this:
ProjectionList projectionList = ProjectionFactoryUtil.projectionList();
projectionList.add(projection1);
projectionList.add(projection2);
dynamicQuery.setProjection(projectionList);
Upvotes: 3