1
我正試圖在兩個對象之間創建一個非常簡單的關係。任何人都可以解釋我爲什麼無法通過findBy方法找到公司對象?爲什麼一對一關係不起作用?
class Company {
String name
String desc
City city
static constraints = {
city(unique: true)
}
}
class City {
String name
static constraints = {
}
}
class BootStrap {
def init = { servletContext ->
new City(name: 'Tokyo').save()
new City(name: 'New York').save()
new Company(name: 'company', city: City.findByName('New York')).save()
def c = Company.findByName('company') // Why c=null????!
}
def destroy = {
}
}
感謝您的幫助!你是對的! – eugenn 2010-06-13 17:25:21