-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: HQL with-clause referenced two different from-clause element
PostPosted: Wed Jun 22, 2016 7:08 am 
Newbie

Joined: Wed Jun 22, 2016 7:03 am
Posts: 1
after several days of research I still have not found the solution.

I have this HQL request that throw a querySyntaxException :

Code:
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: with-clause referenced two different from-clause elements [SELECT patDataset.patient.sId , patData ,proDataset.professional.sId, proData  FROM com.inovelan.cloud.persistence.server.entities.DataSet patDataset INNER JOIN patDataset.patient patient with patient. sId in (:patientSidList) LEFT JOIN patient.patientProfessionals ppRole with ppRole.id.roleCodingOidcodesystem= :codeSystem AND ppRole.id.roleCodingCode=:codingCode  LEFT JOIN ppRole.professional proRole  LEFT JOIN proRole.dataSet proDataset with proDataset.archive =:archive  LEFT JOIN proDataset.dataProfessionals proData with proData.itemDefinition.id.id in (:proItemDefs)  INNER JOIN patDataset.dataSetDefinition patDatasetDef with patDatasetDef.id.id in(:patDatasetDefIdList) INNER JOIN patDataset.dataPatients patData  LEFT JOIN patDataset.dataPatients data_patient_PAT_SEXE with ( data_patient_PAT_SEXE.itemDefinition.id.id=:data_patient_PAT_SEXE AND patDataset.dataSetDefinition.id.id ='DIRECTORY_PATIENT')  LEFT JOIN patDataset.dataPatients data_patient_PAT_NOM_NAISSANCE with ( data_patient_PAT_NOM_NAISSANCE.itemDefinition.id.id=:data_patient_PAT_NOM_NAISSANCE AND patDataset.dataSetDefinition.id.id ='DIRECTORY_PATIENT')  LEFT JOIN patDataset.dataPatients data_patient_PAT_PRENOM with ( data_patient_PAT_PRENOM.itemDefinition.id.id=:data_patient_PAT_PRENOM AND patDataset.dataSetDefinition.id.id ='DIRECTORY_PATIENT')  WHERE patDataset.archive=:archive  AND patient.active=:patientState  AND ( patDatasetDef.id.id =:dataset_def_pat_DIRECTORY_PATIENT AND patData.itemDefinition.id.id in (:itemdef_list_pat_DIRECTORY_PATIENT)  ) AND patDataset.date = (SELECT MAX(patDataset2.date) FROM com.inovelan.cloud.persistence.server.entities.DataSet patDataset2 WHERE patDataset2.dataSetDefinition.id.id = patDataset.dataSetDefinition.id.id AND patDataset2.patient.sId =  patDataset.patient.sId) ORDER BY (CASE WHEN data_patient_PAT_SEXE.stringValue IS NULL then 1 ELSE 0 END), data_patient_PAT_SEXE.stringValue ASC,(CASE WHEN data_patient_PAT_NOM_NAISSANCE.stringValue IS NULL then 1 ELSE 0 END), data_patient_PAT_NOM_NAISSANCE.stringValue ASC,(CASE WHEN data_patient_PAT_PRENOM.stringValue IS NULL then 1 ELSE 0 END), data_patient_PAT_PRENOM.stringValue ASC]
at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:91)
at org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:109)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:284)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:206)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:131)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:93)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:167)
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:236)
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1836)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:342)


I extracted the request to make it more understandable and the reason of this "left join" is to sort metadata (it's not always add to request) :

Code:
SELECT patDataset.patient.sId,
   patData
FROM DataSet patDataset
INNER JOIN patDataset.patient patient
INNER JOIN patDataset.dataSetDefinition patDatasetDef WITH patDatasetDef.id.id IN(:patDatasetDefIdList)
LEFT JOIN patDataset.dataPatients data_patient_PAT_SEXE WITH (data_patient_PAT_SEXE.itemDefinition.id.id='SEXE'
                                                          AND patDatasetDef.id.id ='DIRECTORY_PATIENT')
WHERE patDataset.archive=:archive
AND patient.active=:patientState
ORDER BY (CASE
          WHEN data_patient_PAT_SEXE.stringValue IS NULL THEN 1
          ELSE 0
      END), data_patient_PAT_SEXE.stringValue ASC


I already tried in SQL and what I want to do works perfectly

Code:
LEFT OUTER JOIN dataPatient datapatien1 ON dataset.sId=datapatien1.dataSetSid
AND (datapatien1.itemDefinitionId ='SEXE')
AND datasetdef.id ='DIRECTORY_PATIENT'


I've heard about this issue in hibernate https://hibernate.atlassian.net/browse/HHH-7321 but i work with hibernate 5.2, it should be ok

I've already checked the similar question, but no one has the same case

Thanks for your help


Top
 Profile  
 
 Post subject: Re: HQL with-clause referenced two different from-clause element
PostPosted: Wed Jun 22, 2016 8:10 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
It might be an issue. I think you should provide a replicating test case and create a new JIRA issue.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.