我有以下实体
@Entity
@Table(name = "Person")
public class Person {
@Id
long personId
String firstName
String secondName
...
}
@Entity
@Table(name = "Publisher")
public class Publisher {
@Id
long pId
@OneToOne
@JoinColumn(name = "personID", referenceColumn = "personID")
Person person
...
}
@Entity
@Table(name = "Writer")
public class Writer {
@Id
long wID
@OneToOne(name= "pID", referenceColumn ="pID")
Publisher publisher
...
}
@Entity
@Table(name = "QualtiyBetweenWriterAndPublisher")
public class QualtiyBetweenWriterAndPublisher {
@Id
long writerAndPublisherQualityId
Writer writer
Publisher publisher
String rating
...
}
现在我不确定作家和发布者的QualtiyBetweenWriterAndPublisher实体中的关系吗?以我的理解,这对两个实体都是@OneToOne吗?我是否必须在Writer实体或Publisher实体中包括QualtiyBetweenWriterAndPublisher实体?以后如何保存QualtiyBetweenWriterAndPublisher?我将始终创建对象并设置发布者和人吗?