[英]Hibernate Inheritance and Spring Boot
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? 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".问题是我有一个异常“由:org.postgresql.util.PSQLException:错误:列某物(来自 class A)不存在”。 Are my annotations wrong?
我的注释错了吗?
As far as I know, the abstract class should not be an Entity.据我所知,抽象 class 不应该是实体。 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.而且,就像他说的,class C 不应该是最终的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.