I’m using Hibernate with a version column in my entity class to implement optimistic concurrency control.
Right now I’m implementing redis-caching.
I would like to update the cache just when I .save()
my updated entity in DB.
The problem is that .save()
method in JPA returns the object without incrementing the version field, so the cache becomes outdated.
Of course, I can manually increment the version field right after .save()
, but it doesn’t sound like a good solution at all.
Therefore, is there any solution for such situations?
I’ve also tried .saveAndFlush()
method.
4