我想使用Spring Boot和Hibernate创建一对多的关系
@Entity
@Table(name = "Cluster")
public class Cluster{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
private String project;
@OneToMany(mappedBy = "testclusters", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private Set<Record> records;
我的第二个实体是:
@Entity
@Table(name="Record")
public class Record{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
private String summary;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "id")
private Cluster cluster;
所以我想将集群的id保存到记录表中。
但我一直收到错误:Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.example.clusters.Model.Record.Cluster in com.example.clusters.Model.Cluster.record