My Grails 2.0 app has a User domain object defined:
class User {
static mapping = {
table "dt_user"
columns {
id column: user_id , generator: assigned , type: string
}
}
当我试图拯救我的诱杀装置档案中的新用户时,我这样做:
def user = new User(id: "smith").save(failOnError:true)
我有以下错误:
| Error 2012-01-13 10:09:42,659 [main] ERROR property.BasicPropertyAccessor - IllegalArgumentException in class: User, setter method of property: id
| Error 2012-01-13 10:09:42,660 [main] ERROR property.BasicPropertyAccessor - expected type: java.lang.Long, actual value: java.lang.String
我还试图将用户类别改为:
class User {
static mapping = {
table "dt_user"
columns {
id column: user_id , generator: assigned , type: string , name: id
}
}
String id
}
造成上述错误的错误不复存在。 然而,我发现,这导致婴儿自动产生,完全无视<条码>遗传器:指定编码>条款。
What am I doing wrong here?