我正在使用 Grails 2.2.2、审计跟踪插件 2.0.3 和 spring-security-core 1.2.7.3
当我将注释放在一个类上并使用浏览器(通过 Controller/gsp)插入记录时,一切正常。
@gorm.AuditStamp
class Note {
String name
}
但是,当我在 Bootstrap 中插入记录时
new Note(name:'Testing').save()
我在启动时出错
ERROR property.BasicPropertyAccessor - IllegalArgumentException in class: test.Note, setter method of property: createdBy
ERROR property.BasicPropertyAccessor - expected type: java.lang.Long, actual value: java.lang.Integer
ERROR context.GrailsContextLoader - Error initializing the application: IllegalArgumentException occurred while calling setter of test.Note.createdBy; nested exception is org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of test.Note.createdBy
有没有办法修复在 Bootstrap 期间使审计跟踪工作?我只是在从 Bootstrap 插入时放置默认值,并在使用浏览器屏幕插入时放置登录用户。我使用了以下更改,但仍然没有运气:
static mapping = {
createdBy (defaultValue: Long.valueOf( 1l ))
editedBy (defaultValue: Long.valueOf( 1l ))
}
static constraints = {
createdBy nullable:true
editedBy nullable:true
}
我仍然得到相同的 Long/Integer 错误
编辑:
这是与此 pkugin 相关的我的 Config.groovy 的内容
grails {
plugin{
audittrail{
createdBy.field = "createdBy"
editedBy.field = "editedBy"
createdDate.field = "createdDate"
editedDate.field = "editedDate"
}
}
}