0

次の 2 つのクエリがあり、どちらも同じテーブルをクエリします。1 つのクエリではすべての結果が必要で、2 つ目のクエリでは結果のサブセットが必要です。最後に、2 つのリストが必要です。最初のクエリを 2 番目のクエリと共有する方法はありますか。

    Criteria criteriaPrStatic = this.session.createCriteria(PurchaseRequest.class).add(Restrictions.eq("inactive", false));
    //Would like to use first query again and add the restrictions without having to query the table twice. 
    Criteria criteriaPrDynamic = this.session.createCriteria(PurchaseRequest.class).add(Restrictions.eq("inactive", false));
            criteriaPrDynamic.add(Restrictions.or(
                Restrictions.eq("creator", userInfo.getUser()),
                Restrictions.eq("authorizer", userInfo.getUser())
            ));

    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.groupProperty("currentState"));
    projectionList.add(Projections.rowCount());

    criteriaPrStatic.setProjection(projectionList);
    criteriaPrDynamic.setProjection(projectionList);
4

0 に答える 0