开发者

Grails GORM count function in a named query

I'm writing some named queries for my domain classes in Grails and I've hit a blocker.

Given the following domain class:

class Contributor {
    // evals is a collection of another domain class
    def evals

    static namedQueries = {
        hasNoEvals {
            // Something like this...
  开发者_运维百科          evals.size() == 0
        }
    }
}

Can anyone help with the syntax I need to select the Contributors who have no Evals?

Thanks.


Please look in createCriteria doc for "collection property" operations. In your case, it is isEmpty:

static namedQueries = {
    hasNoEvals {
        isEmpty('evals')
    }
}

For generic size restriction, it is sizeEq, sizeLe and so on.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜