【发布时间】:2019-09-30 05:03:24
【问题描述】:
我无法在 grails 中显示一对一关系。我在 grails > 命令行中使用了 grails create-domain-class 和 grails create-all 并且正在使用 h2 数据库。
class Employee {
int id
String firstName
String lastName
Country country
Classification classification
static constraints = {
}
}
package com.app
class Country {
int id
String countryName
static belongsTo = [employee: Employee]
static constraints = {
}
}
package com.app
class Classification {
int id
String classificationText
static belongsTo = [employee:Employee]
static constraints = {
}
}
我的域类如上所述,在 com.app.Employee 上使用 create-all 后,它会生成剩余点,然后我使用 run-app 启动服务。在 localhost:8080 中显示时,我无法编辑 Country 和 Classification 类变量以使用 countryName 和分类文本。它只显示这些空滚动框。有人知道解决办法吗?
【问题讨论】: