0

What is the proper way to have an abstract class A, inherited by abstract class B, inherited by class C using Hibernate and Spring Boot?

@Entity 
@Inheritance 
abstract class A{} 

@Entity
@Inheritance
abstract class B extends A{}

@Entity 
@Inheritance 
final class C entends B{} 

The problem is I have an exception "Caused by: org.postgresql.util.PSQLException: ERROR: column something(from class A) does not exist". Are my annotations wrong?

1
  • Have you tried @MappedSuperclass? Also, entities shouldn't be final Commented Jun 9, 2020 at 12:59

1 Answer 1

1

As far as I know, the abstract class should not be an Entity. You cannot instanciate it. Try

@MappedSuperclass
public abstract class A {
}
@MappedSuperclass
public abstract class B extends A {
}
@Entity
public class C extends B {
}

And, like he said, class C should not be final.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.