这是我的域类
class ReturnReason implements Serializable {
Long returnReasonId
Long languageId
String name
int hashCode() {
def builder = new HashCodeBuilder()
builder.append returnReasonId
builder.append languageId
builder.toHashCode()
}
boolean equals(other) {
if (other == null) return false
def builder = new EqualsBuilder()
builder.append returnReasonId, other.returnReasonId
builder.append languageId, other.languageId
builder.isEquals()
}
static mapping = {
id composite: ["returnReasonId", "languageId"]
version false
}
static constraints = {
name maxSize: 128
}
}
这是我保存域类的控制器代码。
def save() {
ReturnReason returnReasonInstance = new ReturnReason(params)
returnReasonInstance.languageId = 1
if (!returnReasonInstance.save(flush: true)) {
render(view: "create", model: [returnReasonInstance: returnReasonInstance])
}
redirect(action: "list")
}
在尝试保存在我的控制器中时,returnReasonId 出现错误,即 returnReasonId 拒绝值 null。怎么修。??