0

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.

Shani Mughal
  • 105
  • 13
  • Does this answer your question? [Inherited abstract class with JPA (+Hibernate)](https://stackoverflow.com/questions/3827494/inherited-abstract-class-with-jpa-hibernate) – Mark Dec 13 '19 at 20:38
  • @Mark unfortunately, no. I am confused with that given examples as it has similar names init. if possible you can explain to me in this possible scenerio, Thank you. – Shani Mughal Dec 13 '19 at 21:19

0 Answers0