3 Usage - Reference Documentation
Authors: Diego Toharia
Version: 0.4
3 Usage
Basic usage
Using the plugin is fairly simple. You just need to annotate the domain classes as Timestamped and the dateCreated and lastUpdated properties will be injected at compile time:package my.awesome.grails.appimport com.tado.timestamped.transform.Timestamped@Timestamped class Car { Brand brand String modelName }
Specifiying the properties to inject
By default, all the autotimestamping properties will be injected (at the moment, Grails provides support for dateCreated and lastUpdated ), but you can specify which one you want to avoid:- If you don't want the lastUpdated property to be injected, you can specify to ignore the update event:
package my.awesome.grails.appimport com.tado.timestamped.transform.Timestamped@Timestamped(update=false) // We won't update this, so we don't need the last updated date class Brand { String name Logo logo }
- Accordingly If you don't want the dateCreated property to be injected, you can specify to ignore the update event:
package my.awesome.grails.appimport com.tado.timestamped.transform.Timestamped@Timestamped(create=false) // We don't care about the creation date class Car { Brand brand String modelName }
Specifiying the class of the properties to inject
The Timestamped plugin will try to use the joda-time org.joda.time.Instant class for the timestamped properties, and will fallback to the old and not so good java.util.Date if the previous one is not found, but you can specify your own class:package my.awesome.grails.appimport com.tado.timestamped.transform.Timestamped@Timestamped(clazz='java.lang.Long') class Brand { String name Logo logo }
- Your own specified class
- org.joda.time.Instant class
- java.util.Date class