I have a two entities relationship, I believe that I did all fine, but when I try to run my application, Payara is launching this error:
Caused by: Exception [EclipseLink-7154] (Eclipse Persistence Services - 2.7.4.payara-p2): org.eclipse.persistence.exceptions.ValidationException Exception Description: The attribute [retenciones] in entity class [class komp.model.ChequePropio] has a mappedBy value of [chequepropio] which does not exist in its owning entity class [class komp.model.RetencionChp]. If the owning entity class is a @MappedSuperclass, this is invalid, and your attribute should reference the correct subclass.
Here one of entities causing the problem:
@Entity
@Table(name = "chequepropio", uniqueConstraints = {
@UniqueConstraint(name = "ukchequepropio", columnNames = {"idbanco", "idempresa", "idtipo", "numero"})})
public class ChequePropio implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@OneToMany(fetch = FetchType.LAZY,mappedBy = "chequepropio")
private List<RetencionChp> retenciones;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
The other entities:
@Entity
@Table(name = "retencionchp")
public class RetencionChp implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "idcheque", insertable = true, updatable = true)
private ChequePropio chequePropio;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public ChequePropio getChequePropio() {
return chequePropio;
}
public void setChequePropio(ChequePropio chequePropio) {
this.chequePropio = chequePropio;
}
}
I can't see any error in the relationship, somebody could say me what is wrong?
Thanks in advance!
Fernando
CodePudding user response:
The error is self-explanatory:
The attribute [retenciones] in entity class [class komp.model.ChequePropio] has a mappedBy value of [chequepropio] which does not exist in its owning entity class
Mind the keyword chequepropio
. You don't have a chequepropio
property in RetencionChp
. You have a chequePropio
instead. Mind the uppercase P
. The following should solve it (mappedBy = "chequePropio")
).
@Entity
@Table(name = "chequepropio", uniqueConstraints = {
@UniqueConstraint(name = "ukchequepropio", columnNames = {"idbanco", "idempresa", "idtipo", "numero"})})
public class ChequePropio implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@OneToMany(fetch = FetchType.LAZY,mappedBy = "chequePropio")
private List<RetencionChp> retenciones;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}