Grails 2.0 中的 dateCreated、lastUpdated 字段

2024-04-30

我有一个使用 Grails 1.3.7 的应用程序,我刚刚将其迁移到 Grails 2.0。该应用程序利用自动dateCreated and lastUpdated用于管理与对象的创建和修改相关的时间戳的字段。升级后,我收到以下错误:

| Running Grails application
| Error 2012-01-29 22:36:53,504 [Thread-8] ERROR util.JDBCExceptionReporter  - ERROR: null value in column "date_created" violates not-null constraint
| Error 2012-01-29 22:36:53,510 [Thread-8] ERROR events.PatchedDefaultFlushEventListener  - Could not synchronize database state with session

注释掉我的域类中的上述字段可以使问题消失。

dateCreated and lastUpdatedGrails 2.0 中已弃用字段?如果是这样,这是否意味着我必须编写代码来手动处理此功能,或者代码是否已移动到某种插件中,例如审计追踪 http://grails.org/plugin/audit-trail plugin?


好的,通过在域类定义中手动将 autoTimestamp 变量设置为“true”来修复它:

static mapping = {
        autoTimestamp true
}

我猜想这个属性在将项目从 Grails 1.3.7 迁移到 2.0.0 后没有设置。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Grails 2.0 中的 dateCreated、lastUpdated 字段 的相关文章

随机推荐