具有以下域類:的Grails GORM:地圖查詢
class Word {
Map translations
}
和實例自舉:
def word1 = new Word().with{
translations = [en:"game"]
save(failOnError: true, flush: true)
}
def word2 = new Word().with{
translations = [en:"life"]
save(failOnError: true, flush: true)
}
什麼是常規的方式來獲得所有的字,其中翻譯與startPart
在開始一些locale
?例如:
def listWordsStartsWith(startPart, locale, params){
def regexp = startPart+'%'
def query = Word.where {
//translations[locale] =~ regexp
}
def words = query.list(params)
words
}
感謝您的想法。它應該是這樣的:http://pastie.org/3304152 – tiktak 2012-02-02 18:47:56