I\'m trying to use auditing to save dateCreated
and dateUpdated
in my objects, but since I set ID
manually, there\'s some additional w
Your code is working as expected. After you've implemented Persistable
you can see that @CreatedDate
annotation is working.
Sure that createdDate
is null
on the second call of save
because the object already exists in the database and you updated it with createdDate = null
. As you can see from the documentation for @CreatedDate
:
@CreatedDate annotation. This identifies the field whose value is set when the entity is persisted to the database for the first time.
So not to overwrite your createdDate
with null
on the second call you should retrieve your customer from the database with c = repository.findOne("test_id");
and then update it.