In the @Entity
I have a field:
@CreationTimestamp
@Column(name = "created_at", updatable = false, nullable = false, columnDefinition = "TIMESTAMP")
private LocalDateTime createdAt;
in the @Service
I have:
@Transaction
void someMethod() {
Entity entity = new Entity();
entity.setStatus(someStatus);
entity = entityRepository.save(entity); //here I expect the entity's created_at should be updated
entity.getCreatedAt(); //here I get the null
//some other actions
entityRepository.save(entity);
}
// finally the created_at is set in the db
Are my expectations correct? Is there a way to get this created_at being saved as it would be stored to the DB?