我越來越引起的:javax.persistence.EntityNotFoundException:無法找到tn.entities.AgenceBnq ID爲01,當我通過僱工EntityNotFoundException Hibernate的多對一映射但不存在數據
僱工類獲得AgenceBnq
@Table(name = "EMPLOYE")
@NamedQuery(name = "Employe.findById", query = "SELECT e FROM Employe e where e.employeMat = ?1"),
public class Employe implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "EMPLOYE_MAT", unique = true, nullable = false, length = 15)
private String employeMat;
...
@ManyToOne
@JoinColumn(name = "AGENCE_COD")
private AgenceBnq agenceBnq;
}
@Entity
@Table(name="AGENCEBNQ")
public class AgenceBnq implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name="AGENCE_COD", unique=true, nullable=false, length=10)
private String agenceCod;
...
//bi-directional many-to-one association to Employe
@OneToMany(mappedBy="agenceBnq")
private Set<Employe> employes;
}
我打電話namedQuery Employe.findById DAO中檢索數據,我必須從僱工獲得AgenceBnq但得到這個錯誤,同時呼籲query.getResultList()
@NotFound(action = NotFoundAction.IGNORE)對我來說不是有用的,因爲數據存在於AGENCEBNQ表中,我必須通過Employe 退訂日期這是一個hibernate中的錯誤嗎?我正在使用休眠版本3.6.7.Final
爲什麼它是'e.employeMat =?1'而不僅僅是'e.employeMat =?'? – Jan
我總是使用'?1'作爲參數,它工作正常,即使使用'e.employeMat =?'我也有同樣的問題 –