gpt4 book ai didi

java - 具有持久子类的非持久父类(super class)

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

当我保留这个子类时会发生什么?当我在数据库中查询 Subclass 对象时,变量 a 和 b 是否可用?我怎样才能坚持a和b?

public Superclass {

private int a;
private Obj b;

// ...
}

@Entity
public Subclass extends Superclass{
@id int x;

public Subclass(int a, Obj b, int x){
super(a, b);
}
}

最佳答案

ab 将不会被持久化。

来自https://docs.oracle.com/javaee/6/tutorial/doc/bnbqn.html

Non-Entity Superclasses

Entities may have non-entity superclasses, and these superclasses can be either abstract or concrete. The state of non-entity superclasses is nonpersistent, and any state inherited from the non-entity superclass by an entity class is nonpersistent. Non-entity superclasses may not be used in EntityManager or Query operations. Any mapping or relationship annotations in non-entity superclasses are ignored.

关于java - 具有持久子类的非持久父类(super class),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33546848/

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