Home Grails GORM getting people with both tags
Reply: 0

Grails GORM getting people with both tags

user601
1#
user601 Published in July 16, 2018, 6:19 am

I have the classes:

class Person {
    static hasMany = [tags: Tag]
}

class Tag {
}

To get the people that have at least one of the tags from tagList I could create a criteria

public Criteria hasAtLeastOneOf(List<Tag> tagList) {
    return Person.createCriteria().buildCriteria {
        'tags' {
          'in' 'id', tagList.collect{it.id}
        }
    }
}

What kind of criteria do I need to create to get all the people that have each one of the tags from tagList (eg. tagList[0] and tagList[1], etc.)

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.35051 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO