Antonio mc
Antonio mc

Reputation: 85

Liferay Dynamic query projection with two fields

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

Answers (1)

Andrea Di Giorgi
Andrea Di Giorgi

Reputation: 967

You can do something like this:

ProjectionList projectionList = ProjectionFactoryUtil.projectionList();

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

dynamicQuery.setProjection(projectionList);

Upvotes: 3

Related Questions