Skip to content

Commit 18feb3d

Browse files
committed
Use CREATED and UPDATED for @AutoTimestamp
1 parent 2468a45 commit 18feb3d

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

grails-datastore-gorm-test/src/test/groovy/org/grails/datastore/gorm/CustomAutoTimestampSpec.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ class CustomAutoTimestampSpec extends GormDatastoreSpec {
4040
class RecordCustom {
4141
Long id
4242
String name
43-
@AutoTimestamp(SAVE) Date created
43+
@AutoTimestamp(CREATED) Date created
4444
@AutoTimestamp Date modified
4545
}

grails-datastore-gorm/src/main/groovy/grails/gorm/annotation/AutoTimestamp.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
* Enum to specify when auto-timestamping should occur.
3636
*/
3737
enum EventType {
38-
SAVE,
39-
UPDATE
38+
CREATED,
39+
UPDATED
4040
}
4141

4242
/**
4343
* When to apply auto-timestamping
4444
*/
45-
EventType value() default EventType.UPDATE;
45+
EventType value() default EventType.UPDATED;
4646
}

grails-datastore-gorm/src/main/groovy/org/grails/datastore/gorm/events/AutoTimestampEventListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ protected void storeDateCreatedAndLastUpdatedInfo(PersistentEntity persistentEnt
170170
Field field = getFieldFromHierarchy(persistentEntity, property.getName());
171171
if (field != null && field.isAnnotationPresent(AutoTimestamp.class)) {
172172
AutoTimestamp autoTimestamp = field.getAnnotation(AutoTimestamp.class);
173-
if (autoTimestamp.value() == AutoTimestamp.EventType.UPDATE) {
173+
if (autoTimestamp.value() == AutoTimestamp.EventType.UPDATED) {
174174
storeTimestampAvailability(entitiesWithLastUpdated, persistentEntity, property);
175175
} else {
176176
storeTimestampAvailability(entitiesWithDateCreated, persistentEntity, property);

0 commit comments

Comments
 (0)