【发布时间】:2017-10-07 13:34:44
【问题描述】:
我在数据库中为电影服务设计了一个表系统。到目前为止,我都是这样设计它们的。
@Entity
@Table(name = "movies")
@Data
public class MovieEntity {
@Id
@Column(unique = true, updatable = false)
@GeneratedValue
private Long id;
@OneToMany(mappedBy = "movie", cascade = CascadeType.ALL)
private Set<MovieDescription> description;
}
@Entity
@Table(name = "movies_info")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "type")
public abstract class MovieInfo {
@Id
@Column(unique = true, updatable = false)
@GeneratedValue
private Long id;
@ManyToOne
public MovieEntity movie;
}
@Entity
@DiscriminatorValue(value = EditType.Values.DESCRIPTION)
public class MovieDescription extends MovieInfo {
private String description;
private String language;
}
编译的时候报错
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.core.jpa.entity.MovieDescription.movie in com.core.jpa.entity.MovieEntity.description
与 MovieEnity 映射有关的东西,但我不知道它是什么。
【问题讨论】:
-
您是否使用代码优先方法?如果不是,请提供数据库架构
标签: java spring hibernate spring-mvc spring-boot