JPA @OneToMany with mySql and third join table Without Unique key
JPA @OneToMany with mySql and a third join table Without Unique key
您好,在 @OneToMany
(mySql db) 应用程序中,我想要一个单独的加入 table。
并像这样实施
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long patientInfoId;
@OneToMany
@JoinTable(
name = "patient_health_issues",
joinColumns = {@JoinColumn(name = "patient_id") },
inverseJoinColumns = { @JoinColumn(name = "health_issues_id") }
)
private List<HealthIssues> healthIssues = new ArrayList<HealthIssues>();
它会创建一个单独的连接 table "patient_health_issues"
以 "health_issues_id" 作为唯一键。
我不需要任何唯一键的地方,是否可以控制不生成唯一键。
在这种情况下它不是 @OneToMany
而是 @ManyToMany
您好,在 @OneToMany
(mySql db) 应用程序中,我想要一个单独的加入 table。
并像这样实施
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long patientInfoId;
@OneToMany
@JoinTable(
name = "patient_health_issues",
joinColumns = {@JoinColumn(name = "patient_id") },
inverseJoinColumns = { @JoinColumn(name = "health_issues_id") }
)
private List<HealthIssues> healthIssues = new ArrayList<HealthIssues>();
它会创建一个单独的连接 table "patient_health_issues"
以 "health_issues_id" 作为唯一键。
我不需要任何唯一键的地方,是否可以控制不生成唯一键。
在这种情况下它不是 @OneToMany
而是 @ManyToMany