我想从表Projets(idprojets PK,contrats)和Contracts(idcontrats PK,cont_name)中创建联接表。最终表将为JoinProjetsContrats(idprojet,idcontrat)
到目前为止,这是我的代码:
Projet
@Entity
@Table(name="projets")
public class Projet implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@SequenceGenerator(name="PROJETS_IDPROJET_GENERATOR", sequenceName="PROJETS_IDPROJET_SEQ",allocationSize=1)
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="PROJETS_IDPROJET_GENERATOR")
private Integer idprojet;
@Column(name="charge_totale")
private double chargeTotale;
private String intitule;
private String statut;
//bi-directional many-to-one association to Contrat
@ManyToOne
@JoinColumn(name="idcontrat")
private Contrat contrat;
Contrat:
@Entity
@Table(name="contrats")
public class Contrat implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@SequenceGenerator(name="CONTRATS_IDCONTRAT_GENERATOR", sequenceName="CONTRATS_IDCONTRAT_SEQ",allocationSize=1)
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="CONTRATS_IDCONTRAT_GENERATOR")
private Integer idcontrat;
private String nom;
//uni-directional many-to-many association to Projet
@ManyToMany
@JoinTable(
name="\"joinProjetsContrats\""
, joinColumns={
@JoinColumn(name="idcontrats")
}
, inverseJoinColumns={
@JoinColumn(name="idprojets")
}
)
private Set<Projet> projets1;
//bi-directional many-to-one association to Projet
@OneToMany(mappedBy="contrat")
private Set<Projet> projets2;
我想这里遗漏了一些东西,因为当我创建“ projet”时,更新不在我的SQL表中进行。 Projet表已更新。
对我错过的错误有任何想法吗?
谢谢!