我的表映射出错。 我不知道该如何处理该错误。 你能帮我吗? 非常感谢。
实体和关系:一个RefCollectivite ==>许多ColPlanCompteM61
这是我的代码:
async void
错误:
@Entity
@Table(name = "RefCollectivite")
public class RefCollectivite implements Serializable {
@OneToMany(cascade = CascadeType.REMOVE, mappedBy = "refCollectivite")
private List<ColPlanCompteM61> listePlanCompteM61;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int idPk;
private String libelle;
public RefCollectivite() {
}
@Entity
@Table(name = "ColPlanCompteM61")
public class ColPlanCompteM61 implements Serializable {
@ManyToOne
@JoinColumn(name = "refCollectiviteFk")
private RefCollectivite refCollectivite;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int idPk;
private int refCollectiviteFk;
答案 0 :(得分:0)
您可以尝试以下操作:
@Entity
@Table(name = "RefCollectivite")
public class RefCollectivite implements Serializable {
@OneToMany(cascade = CascadeType.REMOVE)
@JoinColumn(name = "refCollectiviteFk")
private List<ColPlanCompteM61> listePlanCompteM61;
@Entity
@Table(name = "ColPlanCompteM61")
public class ColPlanCompteM61 {
@JoinColumn(name = "refCollectiviteFk", referencedColumnName = "refCollectiviteFk", insertable=false, updatable=false)
private RefCollectivite refCollectivite;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int idPk;
private int refCollectiviteFk;