. and it gets its value as the Entity is created. Can this info be utilized, so that "all saved entity has non-null createdAt" at kotlin level, or do I have to check against null every time? Or I have no choice but declare it as
Copy code
var timestamp: Instant? = null,
d
debop
04/15/2025, 2:26 AM
I use like this
var createdAt: Instant = Instant.now()
protected set
s
Sechaba
04/15/2025, 3:57 AM
No need for var, simple
val createdAt: Instant = Instant.now() also works
Default value is set when you create the entity before passing for repo save
👍 1
Sechaba
04/15/2025, 3:58 AM
Update you use copy and override updatedAt - if you have that field. Assuming you’re using data class of course
p
Pihentagy
04/16/2025, 12:42 PM
Of course no data class.
Pihentagy
04/16/2025, 12:42 PM
Sometimes I need to provide the timestamp manually.