这是具有属性的Provincia类,我想与Pais类(一个Pais有很多Provincia)建立关系ManyToOne
public class Provincia implements Serializable {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "idProvincia")
private Collection<Localidad> localidadCollection;
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "Id")
private Long id;
@Basic(optional = false)
@Column(name = "Nombre")
private String nombre;
@NotNull
@Basic(optional = false)
@ManyToOne
@JoinColumn(name="Pais_ID", referencedColumnName = "Pais_ID")
private Pais idPais;
}
现在是班级Pais及其属性
public class Pais implements Serializable {
private static final long serialVersionUID = 1L;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "idPais")
private Collection<Provincia> provinciaCollection;
@Id
@Basic(optional = false)
@Column(name = "Id")
private Long id;
@Basic(optional = false)
@Column(name = "Nombre")
private String nombre;
}
有人可以帮助我。我在NetBeans 7.3和EclipseLink..thanks
中工作答案 0 :(得分:0)
尝试更改如下
@JoinColumn(name="Pais_ID", referencedColumnName = "Id")
private Pais idPais;