[英]Grails id mapping autoincrement - MySQL
我有一个MySQL表,其ID属性为autoincremental,我需要这样做,当从Grails进行插入时,id的值会自动完成增加。
我的grails类有以下映射:
static mapping = {
id column: "id", type: "long", sqlType: "int", generator: 'assigned'
datasource 'dialer'
version false
}
但是想要进行插入会给我以下错误:
Message: ids for this class must be manually assigned before calling save ()
他们会帮我一把吗? 谢谢!
解决方案是为增量分配remplace
id列:“id”,类型:“long”,sqlType:“int”,generator:'increment'
替换指定的生成器属性
身分
这是为mySQL
static mapping = {
id column: "id", type: "long", sqlType: "int", generator: 'identity'
datasource 'dialer'
version false
}
关于hibernate生成器的更多信息 (ctrl + F“IDENTITY”)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.