提问人:Filip Baszak 提问时间:11/13/2023 最后编辑:BalusCFilip Baszak 更新时间:11/13/2023 访问量:22
超类和子类中的 @PreRemove/@PreUpdate JPA 注释
@PreRemove/@PreUpdate JPA annotations in super and sub classes
问:
升级到 JPA 3.1 后,我遇到了一个问题。 我有超类 A 实体,它有@PreUpdate和 @PreRemove 方法注释来自 jakarta.persistence。
@EntityListeners(AuditingEntityListener.class)
class A {
...
@PreRemove
private void preremoveLogic() { ... }
@PreUpdate
private void preUpdateLogic() { ... }
}
我还有继承 A 类的 B 类和 C 类
class B extends A {
...
@PreRemove
private void preremoveLogicForB() { ... }
@PreUpdate
private void preUpdateLogicForB() { ... }
}
class C extends A {
...
@PreRemove
private void preremoveLogicForC() { ... }
@PreUpdate
private void preUpdateLogicForC() { ... }
}
我的 IDE 将子类中的 @PreRemove 和 @PreUpdate 方法标记为错误:“PreRemove”实体侦听器方法已在类“B/C”或其超类之一中定义
我的问题是:我能否以某种方式覆盖子类中超类中的那些 methoed,以便在每个类中都有@Pre方法?
答: 暂无答案
评论