これらのドメイン クラスを使用すると、次のようになります。
class Country {
static hasMany = [states:State]
}
class State {
static belongsTo = [country: Country]
}
ID で状態を取得できません
def country = new Country()
def state = new State()
country.addToStates(state)
country.save()
def foundState = State.get(state.id)
foundState が null です。データベースから状態を取得する正しい方法は何ですか?