I have these entities;
Person.class
@Entity
@Table(name = "person")
@Inheritance(strategy=InheritanceType.JOINED)
public abstract class Person implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(name = "person_id")
private long personID;
StudentBean.class
@Entity
@Table(name = "student_information")
public class StudentBean extends Person {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
private long studentID;
My goal is to save a student record in 1 table together with the details in the Person class and StudentBean class, but I have encountered these exception
org.hibernate.mapping.JoinedSubclass cannot be cast to org.hibernate.mapping.RootClass
on my research I stumbled upon this thread [Spring 3.1 Hibernate 4 exception for Inheritance cannot be cast to org.hibernate.mapping.RootClass
Based from it, the reason for the exception is due to the @Id in the Parent and Child class. But if I removed the @Id in either of my class, it would not allow me to save the object since I don't have an identifier with my entity.
I want a Person ID to identify a person outside the school and a Student ID to identify a person inside the school, is this possible? if not, how can I remove the PK of the Person class but still I can extend it and save it into another table.
lastly, what is the best way to implement this design, Person can be extended for Student Class, Teacher Class, SchoolPrincipal Class