1
Personal I am trying to make the relationship between two class (Cotdetatlhe and Cotdetforn), but I am 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 a Composite Primary key, a @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.
Just 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;
What’s the Cotdetatlhepk class code? To dry the question, it would also be interesting to clear fields that are not part of the problem (such as Double attributes, for example)
– Dherik
Vlw by @Dherik tip, I already dried the code, only with the necessary and posted the code of the Cotdetatlhepk Table
– Marcelo Jordão