Estoy intentando crear una Unión entre dos tablas, usando HQL (Hibernate Query Language). Esta secuencia de comandos SQL funciona bien en mi servidor SQL:¿Cómo hacer una declaración Union SQL en HQL?
SELECT COUNT(DISTINCT linkedin_id) as test, school_name
FROM
(SELECT * FROM alum_education
UNION
SELECT * FROM alum_connection_educations) AS UNIONS where school_name='some string'
El problema es que cuando intento ejecutarlo en griales como esto:
def countOfEdu = AlumEducation.executeQuery("select count (distinct linkedinId) as countOfEdu, schoolName as SchoolName from (SELECT * FROM alumEducation UNION SELECT * FROM alumConnectionEducations) AS UNIONS where schoolName='some string'")
me sale este error:
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: (near line 1, column 83 [select count(distinct linkedinId) as countOfEdu, schoolName as SchoolName from (SELECT * FROM alumEducation UNION SELECT * FROM alumConnectionEducations) AS UNIONS where schoolName='Duquesne University']
¿Cómo puedo ejecutar la declaración SQL anterior en griales?
gracias Jason
duplicado posible: http://stackoverflow.com/questions/201023/hibernate-union-alternatives –
eliminado Comentario – jellobird