I'm now trying to update the Entity's column by using "getById & save", like below.
// update "title" column
val entityRef = entityRepository.getById(entityID)
entityRef.title = futureTitle
return entityRepository.save(entityRef)
However, if I running the code, the updatedtimestamp column(which is described as CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) not changed even though the column has been perfectly updated.
It seems like the updatedtimestamp
column only updates when I use the custom "UPDATE" query.
@Modifying
@Transactional
@Query("update Entity p set p.title = :newTitle where p.id = :entityId")
fun updateEntityTitle(entityId: Long, newTitle: String)
Could I know why updating entity by "getById & save" didn't made a change to the updatedtimestamp
?
Thanks in advance!