how to find the data by an attribute (name_techno) in jpql

I am developing an application that allows managing candidates in a company, for that I use spring-boot, in order to select the employees who master such a technology (Techno) I used a request JPQL.

So, How can I find a candidate by techno?

In my project I used this code:

1 – the class

public class Candidat {

    @Column(name = "candidat_id")

    private int id;

    private String nom;
    private String prenom;
    private String ville;
    private int numTel;
    private String mail;
    private String pseudo;
    private String roleCible;
    private String typeContrat;
    private String villeRecherchee;

    private List<Techno> techno;

    private Date date;

    private List<SecteurActivites> secteurActivites;

    public Candidat() {
        // TODO Auto-generated constructor stub

2- the class

public class Techno {
    @Column(name = "techno_id")
    private int id ;

    private String nomTechno;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "candidat_id", nullable = false)
    @OnDelete(action = OnDeleteAction.CASCADE)
    private Candidat candidat;
    public Techno() {
        // TODO Auto-generated constructor stub

     * @param nomTechno
     * @param candidat
    public Techno(String nomTechno, Candidat candidat) {
        this.nomTechno = nomTechno;
        this.candidat = candidat;

3- My CandidatController

@GetMapping(value = "/GetAllCandidats/{nomTechno}")
public List<Candidat> afficherCandidat(@PathVariable ("nomTechno")  String nomTechno){

     return  candidatdao.findByTechno(nomTechno);

4- the repository:

public interface CandidatDao extends JpaRepository <Candidat, String>{

    List<Candidat> findByDate(Date date);

    @Query("SELECT DISTINCT e FROM Candidat e INNER JOIN e.Techno t")
    List<Candidat> findByTechno(String nomTechno);


server.port= 9090 = true
spring.datasource.url= jdbc:mysql://localhost:3306/database

The result in console is:

"Validation failed for query for method public abstract java.util.List com.avatar.dao.CandidatDao.findByTechno(java.lang.String)!"


You can declare the following method into your JpaRepository (also remove the @Query, it is not needed).

List<Candidat> findDistinctByTechnoNomTechno(String nomTechno);

Also in you should add the @Column annotation and map it with the DB schema.

I am not sure if you have pasted incomplete code of your entities on purpose. If not your entities are not correct. You should create setters/getters as the following

 private String nomTechno;

@Column(name = "NOM_TECHNO")
public String getNomTechno() {
    return nomTechno;

public void setNomTechno(String nomTechno){
   this.nomTechno = nomTechno;

Do the above for all variables in your entities.