I'm trying to make the relationship between two classes (CotDetatlhe and CotDetForn), but I'm facing the following problem:
The @JoinColumns on the annotated element [field cotDetatlhe] from the entity class [class bean.CotDetForn] is incomplete. When the source entity class uses composite primary key, @JoinColumn must be specified for each join column using the @JoinColumns. Both the name and the referencedColumnName elements must be specified in each such @JoinColumn.
Below are the codes:
CotDetatlhe:
public class CotDetatlhe implements Serializable {
@JoinColumns({
@JoinColumn(name = "cod_req_cab", referencedColumnName = "cod_req_cab", insertable = false, updatable = false),
@JoinColumn(name = "cod_produto", referencedColumnName = "cod_produto", insertable = false, updatable = false)})
@ManyToOne(optional = false)
private ReqDet reqDet
///******* Relação com a classe CotDetForn
@OneToMany(cascade = CascadeType.ALL, mappedBy = "cotDetatlhe")
private Collection<CotDetForn> CotDetFornCollection;
private static final long serialVersionUID = 1L;
@EmbeddedId
protected CotDetatlhePK cotDetatlhePK;
@Basic(optional = false)
@Column(name = "cod_req_det")
private int codReqDet;
@JoinColumn(name = "cod_cot_cab", referencedColumnName = "cod_cot_cab", insertable = false, updatable = false)
@ManyToOne(optional = false)
private CotCab cotCab;
CotDetForn:
public class CotDetForn implements Serializable {
@Transient
private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
private static final long serialVersionUID = 1L;
@EmbeddedId
protected CotDetFornPK cotDetFornPK;
@Column(name = "desconto")
private Integer desconto;
// @Max(value=?) @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
////**** Relação com a classe CotDetatlhe
@JoinColumn(name = "cod_req_det", referencedColumnName = "cod_req_det", insertable = false, updatable = false)
@ManyToOne(optional = false)
private CotDetatlhe cotDetatlhe;
CotDetFornPK:
@Embeddable
public class CotDetFornPK implements Serializable {
@Basic(optional = false)
@Column(name = "cod_det_forn")
private int codDetForn;
@Basic(optional = false)
@Column(name = "cod_cot_forn")
private int codCotForn;
@Column(name = "cod_req_det")
private int codReqDet;
CotDetatlhePK:
@Embeddable
public class CotDetatlhePK implements Serializable {
@Basic(optional = false)
@Column(name = "cod_cot_cab")
private int codCotCab;
@Basic(optional = false)
@Column(name = "cod_req_cab")
private int codReqCab;
@Basic(optional = false)
@Column(name = "cod_produto")
private String codProduto;