I have an abstract superclass entity which is the following:
@Entity
public abstract class Notification {
@id
private int id;
private Stringname;
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
}
Then, I have two class which extends this abstract class
@Entity
public class smsNotifcation extends Notification {
@id
private String name;
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
}
@Entity
public class emailNotifcation extends Notification {
@id
private String name;
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
}
When I use persistence.xml
to auto-create the tables in the PostgreSQL
, it only creates the table for the Notification class
. I am unable to understand why it wont create tables for the other two. If it is not supposed to create them, then how would I map the information. By mapping information, I meant that how will the name
attribute from Notification
class know that to which class this name belongs to i.e the name in abstract class's database belongs to smsNotification
or emailNotification
.