Search code examples
sqljpql

Convert from sql to jpql with clause IN


I have this request in SQL that I have converted in JPQL

===SQL===
 SELECT * FROM ELEVE WHERE ELEVE.AGE IN ('7','8','5','6', '12' ) 

===JPQL===

SELECT E FROM ELEVE E  WHERE E.AGE IN ('7','8','5','6', '12' ) 

But It doesn't work could someone explain me what I missed


Solution

  • you are missing * or the column names after your select , it can be E.* or just * or if you want to specify specific column names it should be like E.columnanme :

    ===SQL===
     SELECT * FROM ELEVE WHERE ELEVE.AGE IN ('7','8','5','6', '12' ) 
    
    ===JPQL===
    
    SELECT E.*  FROM ELEVE E  WHERE E.AGE IN ('7','8','5','6', '12' )