1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
//For the query
ExpressionBuilder theExpBuild = new ExpressionBuilder();
//For the subquery count
ExpressionBuilder theExpCountBuild = new ExpressionBuilder();
ReportQuery subQueryCount = new ReportQuery(FrameLabel.class, theExpCountBuild);
subQueryCount.addCount("nblabelRef", theExpCountBuild.get("aLabelId").distinct());
//For the subquery filter
ExpressionBuilder theSubExpBuild = new ExpressionBuilder();
Expression expShuttle = theSubExpBuild.get("shuttle");
Expression expShuttleIsShipping = expShuttle.get("m_bIsShipping").equal(isShipping);
Expression expRelation = theSubExpBuild.get("aDeliverySiteId").equal(theExpBuild.get("m_lDeliverySiteId"));
//subquery filter
ReportQuery subQueryFilter = new ReportQuery(RelShuttleDeliverySiteLabel.class, expRelation);
subQueryFilter.refreshIdentityMapResult();
subQueryFilter.addCount("countRel", theSubExpBuild.get("aLabelId"));
subQueryFilter.setSelectionCriteria(expRelation.and(expShuttleIsShipping));
//query
Expression greaterThanExp = theExpCountBuild.value("nblabelRef").greaterThan(theExpCountBuild.value("countRel"));
//Expression notExistExp = theExpBuild.get("m_lDeliverySiteId").notExists(subQueryFilter);
ReadAllQuery theQuery = new ReadAllQuery(DeliverySite.class, greaterThanExp);
theQuery.addBatchReadAttribute("m_RelLabels");
List lstDeliverySite = (List) CustomSessionManager.instance().getSession().executeQuery(theQuery);
return getMementoArrayFromList(lstDeliverySite); |
Partager