在Grails / GORM应用程序中,我可以将隐式域id列重命名为entity_id并使用现有序列自动递增吗?
class Practitioner {
Long entityId
String providerName
static mapping = {
id name: 'entityId', column: 'entity_id', generator:'sequence', params:[sequence:'hibernate_sequence']
}
}
尝试在控制台中保存失败,(是的,我的本地Postgres数据库中存在序列)
Practitioner p = new Practitioner(providerName: 'p')
p.save(flush:true, failOnError: true)
错误
grails.validation.ValidationException: Validation Error(s) occurred during save():
- Field error in object
'com.transcendinsights.dp.measureresult.snapshot.Practitioner' on field 'entityId': rejected value [null]; codes
非常感谢您的帮助!