我尝试运行我的projet,但是会出现此错误:
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table if exists public.modele add constraint FKkgs06iwjdxp4r2pnb9num8cgd foreign key (objet_modele_by_objet_id) references public.objet_modele"
通过JDBC语句
@Entity
@Table(name = "modele", schema = "public", catalog = "pfeDb")
public class ModeleEntity {
private String idModele;
private String nomModele;
private ObjetModeleEntity objetModeleByObjetId;
@Id
public String getIdModele() {
return idModele;
}
public void setIdModele(String idModele) {
this.idModele = idModele;
}
public String getNomModele() {
return nomModele;
}
public void setNomModele(String nomModele) {
this.nomModele = nomModele;
}
@ManyToOne
@JoinColumn(name = "objetModeleByObjetId")
public ObjetModeleEntity getObjetModeleByObjetId() {
return objetModeleByObjetId;
}
public void setObjetModeleByObjetId(ObjetModeleEntity
objetModeleByObjetId) {
this.objetModeleByObjetId = objetModeleByObjetId;
}
}
和第二个实体:
@Entity
@Table(name = "objet_modele", schema = "public", catalog = "pfeDb")
public class ObjetModeleEntity {
private int objetId;
private Integer posX;
private Integer posY;
private Integer largeur;
private Integer hauteur;
private Collection<ModeleEntity> modelesByObjetId;
@Id
public int getObjetId() {
return objetId;
}
public void setObjetId(int objetId) {
this.objetId = objetId;
}
@Basic
@Column(name = "pos_x", nullable = true)
public Integer getPosX() {
return posX;
}
public void setPosX(Integer posX) {
this.posX = posX;
}
@Basic
@Column(name = "pos_y", nullable = true)
public Integer getPosY() {
return posY;
}
public void setPosY(Integer posY) {
this.posY = posY;
}
@Basic
@Column(name = "largeur", nullable = true)
public Integer getLargeur() {
return largeur;
}
public void setLargeur(Integer largeur) {
this.largeur = largeur;
}
@Basic
@Column(name = "hauteur", nullable = true)
public Integer getHauteur() {
return hauteur;
}
@OneToMany(mappedBy = "objetModeleByObjetId")
public Collection<ModeleEntity> getModelesByObjetId() {
return modelesByObjetId;
}
public void setModelesByObjetId(Collection<ModeleEntity> modelesByObjetId)
{
this.modelesByObjetId = modelesByObjetId;
}
}