我有兩個物體的關系,我相信我做得很好,但是當我嘗試運行我的應用程式時,Payara 啟動了這個錯誤:
引起:例外 [EclipseLink-7154] (Eclipse Persistence Services - 2.7.4.payara-p2):org.eclipse.persistence.exceptions.ValidationException 例外描述:物體類 [class komp.model.ChequePropio] 中的屬性 [retenciones] ] 有一個 [chequepropio] 的 mappingBy 值,該值在其擁有的物體類 [class komp.model.RetencionChp] 中不存在。如果擁有的物體類是 @MappedSuperclass,則這是無效的,并且您的屬性應參考正確的子類。
這是導致問題的物體之一:
@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;
}
}
其他物體:
@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;
}
}
我看不出關系中有任何錯誤,有人可以告訴我有什么問題嗎?
提前致謝!費爾南多
uj5u.com熱心網友回復:
錯誤是不言自明的:
物體類 [class komp.model.ChequePropio] 中的屬性 [retenciones] 具有 [chequepropio] 的 mappingBy 值,該值在其擁有的物體類中不存在
注意關鍵詞chequepropio。您在 中沒有chequepropio房產RetencionChp。你有一個chequePropio。注意大寫P。以下應該解決它(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;
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/372677.html
