1

私はグルーヴィーを使用しています:

これはうまく機能しますが、[[1,2]、[2,2]] を返すフィールド マッピングが必要です。[[caseId :1, countId: 2], [caseId :2, countId: 2]]のようにする必要があります

def childNotes = ChildNote.withCriteria() {
            createAlias("caseInstance", "caseInstance")
            createAlias("caseInstance.caseTypeInstance", "caseTypeInstance")
            createAlias("childNoteEnteredBy", "childNoteEnteredBy")
           createAlias("assessmentTypeIdAssessmentType", "assessmentTypeIdAssessmentType")
           eq("caseTypeInstance.caseTypeDescrip", "Youth")
           eq("childNoteEnteredBy.id", ccuEmployeeId as Long)
           'in'("assessmentTypeIdAssessmentType.id", assesmentTypes)
           projections { groupProperty("caseInstance" ) 
                count("caseInstance")

               }

        }

これはうまくいきません

 projections { groupProperty("caseInstance" ) as "caseId"
                        count("caseInstance") as "caseCount"

                       }

私も createcriteria を試し、コードでこの例を使用しましたが、 org.hibernate.criterion.ProjectionListを既にインポートしていても、Projections.property 行の「Projections」は認識されません。

List results = session.createCriteria(Domestic.class, "cat")
.createAlias("kittens", "kit")
.setProjection( Projections.projectionList()
    .add( Projections.property("cat.name"), "catName" )
    .add( Projections.property("kit.name"), "kitName" )caseInstance
)
.addOrder( Order.asc("catName") )
.addOrder( Order.asc("kitName") )
.list();

誰でもこれの正しい構文を教えてもらえますか? ありがとう。

4

1 に答える 1