I have such entities with inheritance
@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;
}
during compilation, he throws me away
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
I do not know why he does not see the author
field during mapping.