0

How can i refer my child object to it's parent which are annotated with @MappedSuperclass? These are my classes:

@MappedSuperclass
public class Person extends BaseEntity {}

@Entity
@Table(name = "employee", catalog = "enrollment_system", uniqueConstraints =
@UniqueConstraint(columnNames = {"reference", "emp_number"}))
public class Employee extends Person implements Serializable{}

@MappedSuperclass
public class BackGroundHistory extends BaseEntity {

    @ManyToOne
    @JoinColumn(name = "person_id")
    @ForeignKey(name = "fk_person_history")
    private Person person;

 }

@Entity
@Table(name = "educational_history", catalog = "enrollment_system")
public class EducationalHistory extends BackGroundHistory implements java.io.Serializable {}

and during run time, i am getting this error:

Exception in thread "main" org.hibernate.AnnotationException: @OneToOne or @ManyToOne on entities.EducationalHistory.person references an unknown entity: entities.Person

I am doing this, to avoid multiple declaration on BackGroundHistory class since aside from, class Employee I also have class Applicant and class Student.

Anirudh Lou
  • 781
  • 2
  • 10
  • 28
  • 1
    from that what i remember using jpa ages ago, class with annotation @mappedsuperclass is not entity, and it doesn't have a table, hence cant be used for mapping relations – user902383 Jun 13 '19 at 09:20
  • 1
    Possible duplicate of [Hibernate Mapped Superclass relationships and overriding](https://stackoverflow.com/questions/3227854/hibernate-mapped-superclass-relationships-and-overriding) – user902383 Jun 13 '19 at 09:21

1 Answers1

0

A mapped super-class is not an Entity, it's just used to extends or for inherit property like a ID , CREATE_TIME , UPDATE_TIME ..etc

none
  • 13
  • 6