Search code examples
javamysqlsqlhibernatehql

How to convert this statement from MySQL to HQL?


This is the SQL statement:

SELECT opc.contenido, COUNT(r.idOpcPregunta)  
from  Opcionesrespuestas as opc LEFT JOIN Respuestasimples as r ON r.idOpcPregunta = opc.idOpcPregunta 
where opc.idPregunta ='6' 
GROUP BY opc.idOpcPregunta;

Solution

  • This is the sentence HQL

    select opc.contenido, count(r.idOpcPregunta)   from  Respuestasimples as r
    right join r.idOpcPregunta as opc  where opc.idPregunta ='6'  
    group by opc.contenido