【发布时间】:2020-04-17 06:24:35
【问题描述】:
拥有实体类:
@Entity
class Foo {
@Id
Long id;
@Version
java.time.Instant ts;
}
我需要使用 DB 中 ts 字段的显式值来持久化它。但是,如果我明确设置 ts 的值,它会被 JPA 自动覆盖。
我已经看到了更新的解决方案,但是它对我不起作用,因为我已经在插入时需要它: Is it possible to turn off hibernate version increment for particular update?
我无法删除 @Version,因为它位于我实体的父类中。
此外,我一般无法禁用该行为。仅在特定用例中需要它。
【问题讨论】: