Reputation: 886
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);
}
}
Upvotes: 1
Views: 227
Reputation: 1312
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.
Upvotes: 2