Problem with a HQL query

Hi all,

I am new in HQL using and try to create an HQL query to use it in Jaspersoft studio

My query is:

select
pol.Polt1 as code_imputation,
cpt.Description as desc_imputation,
pol.Id.FkCodePurchaseorder as cda,
po.Pot2 as cda_gxa
from
TblPurchaseorderline pol, TblPurchaseorder po, TblGlaccountseg cpt
left join fetch pol.TblLocation loc
where
pol.Id.FkCodeSite = $P{SITE} and pol.Id.FkCodeOrganisation = $P{ORG} and
(pol.Id.FkCodePurchaseorder = po.Id.CodePurchaseorder and po.Id.FkCodeSite = pol.Id.FkCodeSite and po.Id.FkCodeOrganisation = pol.Id.FkCodeOrganisation) and
(pol.Polt1 = cpt.Id.CodeGlaccountseg and cpt.Id.Segmenttype = ‘SEG1’ and cpt.Id.FkCodeOrganisation = pol.Id.FkCodeOrganisation) and
(pol.Polt1 = loc.FkCodeGlaccountseg1 and loc.Id.FkCodeSite = pol.Id.FkCodeSite and loc.Id.FkCodeOrganisation = pol.Id.FkCodeOrganisation)

When I try to run it, I have this error:

net.sf.jasperreports.engine.JRException: org.hibernate.QueryException: could not resolve property: TblLocation of: altair.dao.TblPurchaseorderline [select
pol.Polt1 as code_imputation,
cpt.Description as desc_imputation,
pol.Id.FkCodePurchaseorder as cda,
po.Pot2 as cda_gxa
from
altair.dao.TblPurchaseorderline pol, altair.dao.TblPurchaseorder po, altair.dao.TblGlaccountseg cpt
left join fetch pol.TblLocation loc
where
pol.Id.FkCodeSite = :_SITE and pol.Id.FkCodeOrganisation = :_ORG and
(pol.Id.FkCodePurchaseorder = po.Id.CodePurchaseorder and po.Id.FkCodeSite = pol.Id.FkCodeSite and po.Id.FkCodeOrganisation = pol.Id.FkCodeOrganisation) and
(pol.Polt1 = cpt.Id.CodeGlaccountseg and cpt.Id.Segmenttype = ‘SEG1’ and cpt.Id.FkCodeOrganisation = pol.Id.FkCodeOrganisation) and
(pol.Polt1 = loc.FkCodeGlaccountseg1 and loc.Id.FkCodeSite = pol.Id.FkCodeSite and loc.Id.FkCodeOrganisation = pol.Id.FkCodeOrganisation)]

at com.jaspersoft.studio.editor.preview.view.control.ReportControler.fillReport(ReportControler.java:548)

at com.jaspersoft.studio.editor.preview.view.control.ReportControler.access$20(ReportControler.java:523)

at com.jaspersoft.studio.editor.preview.view.control.ReportControler$5.run(ReportControler.java:404)

at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Caused by: org.hibernate.QueryException: could not resolve property: TblLocation of: altair.dao.TblPurchaseorderline [select
pol.Polt1 as code_imputation,
cpt.Description as desc_imputation,
pol.Id.FkCodePurchaseorder as cda,
po.Pot2 as cda_gxa
from
altair.dao.TblPurchaseorderline pol, altair.dao.TblPurchaseorder po, altair.dao.TblGlaccountseg cpt
left join fetch pol.TblLocation loc
where
pol.Id.FkCodeSite = :_SITE and pol.Id.FkCodeOrganisation = :_ORG and
(pol.Id.FkCodePurchaseorder = po.Id.CodePurchaseorder and po.Id.FkCodeSite = pol.Id.FkCodeSite and po.Id.FkCodeOrganisation = pol.Id.FkCodeOrganisation) and
(pol.Polt1 = cpt.Id.CodeGlaccountseg and cpt.Id.Segmenttype = ‘SEG1’ and cpt.Id.FkCodeOrganisation = pol.Id.FkCodeOrganisation) and
(pol.Polt1 = loc.FkCodeGlaccountseg1 and loc.Id.FkCodeSite = pol.Id.FkCodeSite and loc.Id.FkCodeOrganisation = pol.Id.FkCodeOrganisation)]

at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:67)

at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:61)

at org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:1375)

at org.hibernate.hql.ast.tree.FromElementType.getPropertyType(FromElementType.java:304)

at org.hibernate.hql.ast.tree.FromElement.getPropertyType(FromElement.java:410)

at org.hibernate.hql.ast.tree.DotNode.getDataType(DotNode.java:617)

at org.hibernate.hql.ast.tree.DotNode.prepareLhs(DotNode.java:263)

at org.hibernate.hql.ast.tree.DotNode.resolve(DotNode.java:210)

at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:117)

at org.hibernate.hql.ast.HqlSqlWalker.createFromJoinElement(HqlSqlWalker.java:369)

at org.hibernate.hql.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:3452)

at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3239)

at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3112)

at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:720)

at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:571)

at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:288)

at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:231)

at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:254)

at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185)

at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)

at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)

at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)

at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)

at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)

at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)

at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1651)

at net.sf.jasperreports.engine.query.JRHibernateQueryExecuter.createQuery(JRHibernateQueryExecuter.java:279)

at net.sf.jasperreports.engine.query.JRHibernateQueryExecuter.createDatasource(JRHibernateQueryExecuter.java:195)

at net.sf.jasperreports.engine.fill.JRFillDataset.createQueryDatasource(JRFillDataset.java:1245)

at net.sf.jasperreports.engine.fill.JRFillDataset.initDatasource(JRFillDataset.java:723)

at net.sf.jasperreports.engine.fill.BaseReportFiller.setParameters(BaseReportFiller.java:438)

at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:550)

at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:396)

at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:732)

at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:59)

at net.sf.jasperreports.engine.fill.AbstractThreadSubreportRunner.run(AbstractThreadSubreportRunner.java:221)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at java.lang.Thread.run(Thread.java:745)

I don’t understand where my problem is.

Could you help me please ?