在 grails 中,我有三个类,例如:
1.
package com.p1
class Node {
static constraints = {
name(blank:false,nullable:true)
}
String name
static mapping = {
discriminator column:"Node_Type"
}
String toString() {
"$name"
}
}
2.
package com.p1
class Task extends Node {
static constraints = {
}
static mapping = {
discriminator value:"TASK_NODE"
}
}
3.
package com.p1
class Decision extends Node{
static constraints = {
assignee(nullable:true)
}
String assignee
static mapping = {
discriminator value:"DECISION_NODE"
}
}
在 MySQL 表中,我可以将鉴别器列名获取为Node_Type
,但无法获取 and 之类的TASK_NODE
列值DECISION_NODE
。
相反,我变得像这样[com.p1.Task
或com.p1.Decision
]