Hello,
I use an entity "Commentaire" with a composite primary key and in this key, I have a foreign key on another entity (Journal).
@NamedQueries( {
@NamedQuery(name="commentaire.findAll",
query="FROM Commentaire"),
@NamedQuery(name="commentaire.findByActivite",
query= "FROM Commentaire " +
"WHERE actif = :activite"),
@NamedQuery(name="commentaire.findByDate",
query= "FROM Commentaire " +
"WHERE date = :date"),
@NamedQuery(name="commentaire.findByGestionnaire",
query= "FROM Commentaire " +
"WHERE gestionnaire = :gestionnaire"),
@NamedQuery(name="commentaire.findByMouvement",
query= "FROM Commentaire " +
"WHERE annee = :annee AND journal.idJournal = :idJournal AND chrono = :chrono")
})
@Entity
@IdClass(CommentairePk.class)
@Table(name="SCHEMA.COMMENTAIRE")
public class Commentaire implements Serializable {
private static final long serialVersionUID = -2679761258372320963L;
private String annee;
private Journal journal;
private int chrono;
private String gestionnaire;
private Date date;
private String commentaire;
private Boolean actif;
private SysInfo sysInfo;
@Id
public String getAnnee() {
return annee;
}
public void setAnnee(String annee) {
this.annee = annee;
}
@ManyToOne(cascade={CascadeType.ALL})
@JoinColumn(name="IDJOURNAL")
@Id
public Journal getJournal() {
return journal;
}
public void setJournal(Journal journal) {
this.journal = journal;
}
@Id
public int getChrono() {
return chrono;
}
public void setChrono(int chrono) {
this.chrono = chrono;
}
@Id
public String getGestionnaire() {
return gestionnaire;
}
public void setGestionnaire(String gestionnaire) {
this.gestionnaire = gestionnaire;
}
@Id
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
....
}
org.hibernate.QueryException: could not resolve property: idJournal