有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Hibernate@AttributeOverride,这会导致将属性设置为@Transient

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

给定映射超类:

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

共 (1) 个答案

  1. # 1 楼答案

    这是不可能的。Javadoc of @AttributeOverride

    (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中的一个来寻找另一个设计