使用这些域类:
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 为空。从数据库中检索状态的正确方法是什么?