What happens when I persist this subclass? Are the variables a and b available when I'd query the database for the Subclass object? How can I persist a and 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);
}
}
a
and b
will not be persisted.
From 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.