Sto provando a creare un'unione tra due tabelle, usando HQL (Hibernate Query Language). Questo script SQL funziona bene sul mio server SQL:Come eseguire un'istruzione SQL Union in 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'
Il problema è che quando provo a farlo funzionare in graal in questo modo:
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'")
ottengo questo errore:
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']
Come posso eseguire l'istruzione SQL sopra riportata in Grails?
grazie jason
Eventuali duplicati: http://stackoverflow.com/questions/201023/hibernate-union-alternatives –
eliminato commento – jellobird