Automatic Values

Several AttributeListener classes include features for setting values automatically.

If you specify @Attribute(listener = ModificationDate.class), the class overwrites the property value with the current date and time when you save the model. This is useful when you want to keep track of the last time when a model was saved.
@Attribute(listener = ModificationDate.class)
Date updatedAt;

If you specify @Attribute(listener = CreationDate.class), the property is set to the current time only when the model is saved for the first time. Subsequent saves do not overwrite the value.
@Attribute(listener = CreationDate.class)
Date createdAt;

CreationUser, ModificationUser, CreationEmail and ModificationEmail are prepared, too.

Next...

Continue to Model Attributes and Entity Properties.


Comments