热卖商品
新闻详情
hibernate.QueryException: query specified join fetching, but...
来自 : www.iteye.com/problems/31...
发布时间:2021-03-25
比较诡异,我看我的hql语句也没有什么问题,可执行后总是抛出这个异常:
hql语句为
有哪位知道的,期待把答案给贴出来。
经过测试我发现当我把hql语句中的fetch给去掉以后就没有了异常,也得到了正确的结果,我比较郁闷的原因是因为我明明使用的是Lazy连接,怎么可能就不使用fetch不抛出异常呢。
Caused by: org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list [FromElement{explicit,not a collection join,fetch join,fetch non-lazy properties,classAlias=chemicalInfo,role=null,tableName=cims_chemicalinfo,tableAlias=chemicalin1_,origin=bio_chemical_info biochemica0_,colums={biochemica0_.cims_chemicalinfo_id ,className=com.founder.cims.crt.model.ChemicalInfo}}] [select regStructure.formula, chemicalInfo.corpID, assayValue.value from com.founder.cims.bio.model.BioChemicalInfo bioChemicalInfo left join fetch bioChemicalInfo.chemicalInfo chemicalInfo left join chemicalInfo.regStructure regStructure left join fetch bioChemicalInfo.experimentProcessRecord experimentProcessRecord left join fetch experimentProcessRecord.assayValues assayValue ] at org.hibernate.hql.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:217) at org.hibernate.hql.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:727) at org.hibernate.hql.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:551) at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:645) at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281) at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229) at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:251) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:183) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:134) 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:1650) at org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:923) at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419) ... 29 more
hql语句为
select chemicalInfo.corpID, assayValue.value from BioChemicalInfo bioChemicalInfo left join fetch bioChemicalInfo.chemicalInfo chemicalInfo left join fetch bioChemicalInfo.experimentProcessRecord experimentProcessRecord left join fetch experimentProcessRecord.assayValues assayValue
有哪位知道的,期待把答案给贴出来。
经过测试我发现当我把hql语句中的fetch给去掉以后就没有了异常,也得到了正确的结果,我比较郁闷的原因是因为我明明使用的是Lazy连接,怎么可能就不使用fetch不抛出异常呢。
本文链接: http://joinchemicals.immuno-online.com/view-775756.html
发布于 : 2021-03-25
阅读(0)
最新动态
2021-03-25
2021-03-25
2021-03-25
2021-03-25
2021-03-24
2021-03-25
2021-03-25
2021-03-24
2021-03-24
2017-10-17
2021-03-25
2021-03-25
联络我们