我想做的一件事是对我们数据库中的条目进行版本控制。在我的更新方法中,我想保存一个对象的更新的第二个版本。例如
def update = {
def VariantInstance = Variant.get(params.id)
def NewVariantInstance = VariantInstance
NewVariantInstance.properties = params
if (VariantInstance) {
if (!VariantInstance.hasErrors()) {
VariantInstance.save()
NewVariantInstance.save()
flash.message = "${message(code: 'default.updated.message', args: [message(code: 'Variant.uniqueIdentifyingName', default: 'Variant'), VariantInstance.id])}"
redirect(action: "list")
}
else {
render(view: "edit", model: [VariantInstance: VariantInstance])
}
}
else {
flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'Variant.uniqueIdentifyingName', default: 'Variant'), params.id])}"
redirect(action: "list")
}
}
虽然这会保存当前的,但不会创建新的。我究竟做错了什么?