dateCreated, lastUpdated fields in Grails 2.0
Grails 2.0 still supports the automatic timestamps. It's listed in the manual (scroll up a bit from this link).
However, it specifically mentions:
If you put
nullable: false
constraints on eitherdateCreated
orlastUpdated
, your domain instances will fail validation - probably not what you want. Leave constraints off these properties unless you have disabled automatic timestamping.
Ok, fixed it by manually setting the autoTimestamp variable to "true" in the domain class definitions:
static mapping = {
autoTimestamp true
}
I would guess that this property is not set after migrating a project from Grails 1.3.7 to 2.0.0.
There is a bug in Grails 2.0.3 that can cause this problem when using Postgres. See http://jira.grails.org/browse/GRAILS-8988. The issue says it will resolved when 2.0.4 is released.