在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
,但我无法获得列值,如TASK_NODE
和DECISION_NODE
。
相反,我会这样[com.p1.Task
或com.p1.Decision
]