开发者

How to findByAll with a Domain hasMany member?

I have:

static hasMany = [
    services:String,
    tags:String
]

I need to search the database for services.

Thi开发者_如何学Gos is the JSON for services

 "services":["tid.2","tid.3"]

If services was a String (service) and not a hasMany String then tbis works

def inUse = ServiceTemplate.findAllByName(serviceTemplateInstance.service).size() > 1

How can I do this with services?

I've tried

            def c = ServiceTemplate.createCriteria()
            def results = c.list { eq('services', 'tid.2') }

but no luck...


You can use HQL instead. For example:

ServiceTemplate.findAll("from ServiceTemplate st where :service in elements(st.services)", [service:'a'])
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜