【发布时间】:2010-06-13 15:54:16
【问题描述】:
我试图在两个对象之间创建一个非常简单的关系。谁能解释一下为什么我无法通过 findBy 方法找到 Company 对象?
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 = {
}
}
【问题讨论】:
标签: grails grails-orm