我有这样的实体继承
@MappedSuperclass
public class PostEntity {
...
@ManyToOne
@JoinColumn(name = "user_id")
private UserEntity author;
}
@Entity
@Table(name = "answers")
public class AnswerEntity extends PostEntity {}
@Entity
@Table(name = "users")
public class UserEntity {
...
@OneToMany(mappedBy = "author", cascade = CascadeType.ALL, fetch = FetchType.LAZY, orphanRemoval = true)
private List<AnswerEntity> answers;
}
在编译期间,他把我扔掉了
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.example.demo.jpa.entity.AnswerEntity.author in com.example.demo.jpa.entity.UserEntity.answers
我不知道为什么他在映射过程中没有看到author
字段。
答案 0 :(得分:0)
JPA不支持它,至少不支持Hibernate。你可以有:
<speak>
1. The numbers are: <say-as interpret-as="digits">5498</say-as>.
2. The numbers are: <say-as interpret-as="spell-out">5498</say-as>.
3. The numbers are: <say-as interpret-as="characters">5498</say-as>.
4. The numbers are: <prosody rate="x-slow"><say-as interpret-as="digits">5498</say-as></prosody>.
5. The number is: 5498.
</speak>
或将@OneToMany(mappedBy = "author")
private List<PostEntity> answers;
字段移至AnswerEntity。