0
我已經休眠的實體,稱爲提供商如下許多關係,很多在實體
@Entity
@Table
public class Provider {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private long id;
@Column
private String name;
@Column
private String type;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
它包含了不同類型的基於類型的供應商,
- 學生提供商 - 類型爲ST
- 對於培訓機構 - 類型是CP
在這裏,我需要作出許多一對多重lationship
public class StudentToCourseProvider {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@ManyToOne
@JoinColumn(name = "student_id")
private Provider studentProvider;
@ManyToOne
@JoinColumn(name = "course_id")
private List<Provider> courseProvider;
public Provider getStudentProvider() {
return studentProvider;
}
public void setClinicalProvider(Provider studentProvider) {
this.studentProvider = studentProvider;
}
public Provider getCourseProvider() {
return courseProvider;
}
public void setCourseProvider(Provider courseProvider) {
this.courseProvider = courseProvider;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
}
之間的學生提供商和我創造了一個新的實體如下當然provider.For,我需要沒有ID(主鍵)創建StudentToCourseProvider實體。如何做到這一點?
感謝您的評論,你可以請更詳細解釋,我不明白如何使用繼承來創建實體 – user1321824 2012-04-16 09:25:48