Search code examples
javahibernatejpaspring-datajpql

Want to pass String to Query Spring data with @query


I just want to pass two string to my query with Spring data, my query looks like :

@Query("select ts.talent from T_LinkTalentSkill ts , where ts.skill || '_'||ts.lnLevel in (a,b) group by 1 having count(*)=2 ")
public List<T_Talent> searchBySkillTalent(@Param("a") String a,@Param("b") String b);

i tried to pass a and b but i got : Validation failed for query


Solution

  • To use @Query annotation with native queries you need to use nativeQuery flag with true value, please check below code:

    @Query(value = "select ts.talent from T_LinkTalentSkill ts  where ts.lnLevel in (?1,?2) group by 1 having count(*)=2", nativeQuery = true)
    List<T_Talent> searchBySkillTalent(String a,String b);