Having the entity class:
@Entity
class Foo {
@Id
Long id;
@Version
java.time.Instant ts;
}
I need to persist it with the explicit value of ts
field in DB. However if I set the value of ts explicitly, it's overwritten by the JPA automatically.
I've seen the solution for the update, however it's not working for me, as I need it on insert already: Is it possible to turn off hibernate version increment for particular update?
I can't remove the @Version
as it's in the parent class of my entity.
Moreover, I can't disable the behaviour in general. Would need it for the specific use-case only.