0 Replies Latest reply on Aug 22, 2007 10:28 AM by Jonathan Courtoy

    Foreign key in a composite primary key

    Jonathan Courtoy Newbie


      I use an entity "Commentaire" with a composite primary key and in this key, I have a foreign key on another entity (Journal).

      @NamedQueries( {
       query="FROM Commentaire"),
       query= "FROM Commentaire " +
       "WHERE actif = :activite"),
       query= "FROM Commentaire " +
       "WHERE date = :date"),
       query= "FROM Commentaire " +
       "WHERE gestionnaire = :gestionnaire"),
       query= "FROM Commentaire " +
       "WHERE annee = :annee AND journal.idJournal = :idJournal AND chrono = :chrono")
      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;
       public String getAnnee() {
       return annee;
       public void setAnnee(String annee) {
       this.annee = annee;
       public Journal getJournal() {
       return journal;
       public void setJournal(Journal journal) {
       this.journal = journal;
       public int getChrono() {
       return chrono;
       public void setChrono(int chrono) {
       this.chrono = chrono;
       public String getGestionnaire() {
       return gestionnaire;
       public void setGestionnaire(String gestionnaire) {
       this.gestionnaire = gestionnaire;
       public Date getDate() {
       return date;
       public void setDate(Date date) {
       this.date = date;

      But when I launch my test on this entity, I have this exception :
      org.hibernate.QueryException: could not resolve property: idJournal

      When I remove journal from the primary key, it's all right.

      Someone has a solution ?

      Thank you