2014-09-28 42 views
1

我需要在多個字段中使用具有投影的動態查詢。類似的東西Liferay具有兩個字段的動態查詢投影

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")))); 

非常感謝提前!

回答

3

你可以做這樣的事情:

ProjectionList projectionList = ProjectionFactoryUtil.projectionList(); 

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

dynamicQuery.setProjection(projectionList);