Saturday, July 6, 2013

Grails automatic timestamp

In your domain class, you can add a field which has automatic timestamp (When creating or when updating).
The date field must have the name dateCreated or lastUpdated.
It's a convention define by Grails.

Example :

class Person {
   Date dateCreated
   Date lastUpdated
}
 
 
If you want to disable this feature, you can make the following :
 
class Person {
   Date dateCreated
   Date lastUpdated
   static mapping = {
      autoTimestamp false
   }
} 

See also :

No comments:

Post a Comment