gpt4 book ai didi

java - Hibernate @AttributeOverride 导致将属性设置为@Transient

转载 作者:行者123 更新时间:2023-11-30 11:28:05 24 4
gpt4 key购买 nike

除此之外,如果这样做是正确的模式,那么问题是在 Hibernate 中是否可以为给定的 @MappedSuperclass 将覆盖属性设置为 @Transient 或以任何“其他方式”忽略它?

给定的映射父类(super class):

@MappedSuperclass
public abstract class MappedSuperclassEntity {
private Integer field;
public Integer getField() {return field;}
public void setField(Integer field) {this.field = field;}
}

最佳答案

那是不可能的。 @AttributeOverride 的 Javadoc:

(Required) The column that is being mapped to the persistent attribute. The mapping type will remain the same as is defined in the embeddable class or mapped superclass.

可以看三者之一inheritance strategies for JPA here另一种设计。

关于java - Hibernate @AttributeOverride 导致将属性设置为@Transient,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19030661/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com