包含枚举集的Grails查询模型

包含枚举集的Grails查询模型,grails,model,enums,querying,Grails,Model,Enums,Querying,我的域类是 class RoomWantedAd{ Set<MateAgeRange> mateAgeRanges static hasMany=[mateAgeRanges :MateAgeRange] } 我的问题是搜索。在搜索页面中,用户可以在[18-29、30-39、40-49、50-59、60+]中选择0或更多值。在db中,[18-29、30-39、40-49、50-59、60+]中的0或更多值存储在字段“mateAgeRanges”中。 让db在“Mat

我的域类是

class RoomWantedAd{
    Set<MateAgeRange> mateAgeRanges
    static hasMany=[mateAgeRanges :MateAgeRange]
}
我的问题是搜索。在搜索页面中,用户可以在[18-29、30-39、40-49、50-59、60+]中选择0或更多值。在db中,[18-29、30-39、40-49、50-59、60+]中的0或更多值存储在字段“mateAgeRanges”中。
让db在“MateAgerRange”字段中包含[30-39,50-59]。在搜索页面中,用户选择[18-29,50-59,60+]。然后必须返回与上述列表对应的Ad。这是因为数据库列表中至少存在用户选择中的一个值。这怎么可能。是否可以使用SQL查询或grails GORM查询

您必须使用与用于创建/更新的标签完全相同的标签。因此,您将在浏览器中看到人类可读的值,如30,但在后台将使用“30-39”值。

搜索页面UI正常。UI和值工作正常。我的问题是关于质疑。这个问题是如何被查询的。不要理解它。您可以根据从表单中获取的数据进行查询。这里还需要什么?我实际上想知道与此问题对应的sql查询在DataSource.groovy:hibernate{cache.use_second_level_cache=true cache.use_query_cache=false show_sql=true format_sql=true}
enum MateAgeRange {
    TWENTIES('18-29')
    ,THIRTIES('30-39')
    ,FOURTIES("40-49")
    ,FIFTIES("50-59")
    ,SIXTIES("60+")



final String value

private MateAgeRange(String value) {
    this.value = value
}

String toString() { value }
String getKey() { name() }


static belongsTo=[roomWanted:RoomWanted]
}