Grails Criteria distinct doesn't work

221 Views Asked by At

In my app I use createCriteria for getting a list according some criteria. roleMapping contains user.

I use the following code:

def getTeamOfCompany(def company,def offset=0){
        def c = roleMapping.createCriteria()
        def result = c.list{
            eq('company',company)
            eq('isCurrentCompany',true)
            firstResult offset
            maxResults 10
            distinct('user')
            user{
                order "lastname", "asc"
            }
        }
    return result
}

I use the distinct in order to not get the same user twice, but it didn't work.

If I put projections on the distinct I'll get a list of users instead roleMapping

0

There are 0 best solutions below