Reputation: 49
to better explain the problem
the code of class Colaborateur
private Integer idColaborateur;
private Rolecol rolecol;
private String matriculeColaborateur;
private String nomColaborateur;
private String prenomColaborateur;
private String mailColaborateur;
private String pwdColaboratuer;
private String loginColaborateur;
private String adresseColaborateur;
private Boolean flgSuspendu;
// getter and setter
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "colaborateur")
public Set<NoteObjectifs> getNoteObjectifses() {
return this.noteObjectifses;
}
code of class NoteObjectifs
private Integer idNoteObjectif;
private Colaborateur colaborateur;
private CompagneDevaluation compagneDevaluation;
private Appreciation appreciation;
private Integer moyenneFinale;
private String objectif;
private Integer poid;
// getter and setter
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "idColaborateur")
public Colaborateur getColaborateur() {
return this.colaborateur;
}
NoteObjectifsDAO
public List<NoteObjectifs> findByMatriculecol(String matriculecolaborateur){
String queryString = "String queryString = "select c from NoteObjectifs n inner join n.colaborateur c where c.matriculeColaborateur = ? ";
return getHibernateTemplate().find(queryString);
}
Exception
Expected positional parameter count: 1, actual parameters: [] [select c from NoteObjectifs n inner join n.colaborateur c where c.matriculeColaborateur = ? ]
I have a problem with HQL query I would like to view the goals(noteobjectif) of employee(colaborateur) by their matricule
Upvotes: 0
Views: 37
Reputation: 599
The exception here is not related with the join... you are not declaring the parameter, which you must. The fix is something like this:
return getHibernateTemplate().find(queryString, matriculecolaborateur);
If I may suggest one more thing: create a named query for these kind of "static" queries. NamedQueries are compiled at startup time not during runtime, hence littlebit faster. Plust you have them declared in one place (either in annotation at the top of the class, or in xml).
Good luck.
Upvotes: 1