When migrating from Hibernate 3.1RC2 to 3.1.2, we encountered same error as shown above, but using the same query scheme, as in documentation:
This hql query
Code:
select p from Person p left join fetch p.events where p.id = :pid
Throws
Code:
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=null,role=null,tableName=TIPSYS_ODDS.OPPORTUNITY_TYPES,tableAlias=opportunit3_,origin=TIPSYS_ODDS.OPPORTUNITY_TYPE_OPTIONS opportunit2_,colums={opportunit2_.OPPORTUNITY_TYPE ,className=cz.tipsport.tipsys.odds.bo.OpportunityType}}] [select eventPattern from cz.tipsport.tipsys.odds.bo.EventPattern eventPattern left join fetch eventPattern.eventPatterns2OpportunityTypeOptions ep2otos left join fetch ep2otos.opportunityTypeOption.opportunityType where eventPattern.competition.id = 22]
at org.hibernate.hql.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:190)
at org.hibernate.hql.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:637)
at org.hibernate.hql.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:466)
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:218)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:109)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:134)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:113)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1602)
at test.hibernate.UserManager.test(UserManager.java:84)
at test.hibernate.UserManager.main(UserManager.java:14)
When
select p is removed from query, everything works fine. I know, that this
select p is redundant, but I thing it should work.
Kind regrads
Lubos Lipinsky