[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-6593?page=c...
]
Christian Beikov commented on HHH-6593:
---------------------------------------
The problem with the workaround is, that a select distinct will not work anymore, because
join fetching sub collections without the alias will end up in the following Exception:
org.hibernate.QueryException: query specified join fetching, but the owner of the fetched
association was not present in the select list [FromElement{explicit,collection join,fetch
join,fetch non-lazy
properties,classAlias=null,role=package.MyClass.mapField,tableName={none},tableAlias=map_field1_,origin=null,columns={,className=null}}]
[SELECT DISTINCT ...]
at org.hibernate.hql.ast.tree.SelectClause.initializeExplicitSelectClause(Unknown
Source)
at org.hibernate.hql.ast.HqlSqlWalker.useSelectClause(Unknown Source)
at org.hibernate.hql.ast.HqlSqlWalker.processQuery(Unknown Source)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(Unknown Source)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(Unknown Source)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(Unknown Source)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(Unknown Source)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(Unknown Source)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(Unknown Source)
at org.hibernate.engine.query.HQLQueryPlan.<init>(Unknown Source)
at org.hibernate.engine.query.HQLQueryPlan.<init>(Unknown Source)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(Unknown Source)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(Unknown Source)
at org.hibernate.impl.AbstractSessionImpl.createQuery(Unknown Source)
at org.hibernate.impl.SessionImpl.createQuery(Unknown Source)
This has to work, it is essential for writing HQL queries. I can not imagine that no one
had this problem before! Please take care of that bug asap!
Fetch joining subelements of a one-to-one or many-to-one association
--------------------------------------------------------------------
Key: HHH-6593
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-6593
Project: Hibernate ORM
Issue Type: Bug
Affects Versions: 3.6.6
Reporter: Christian Beikov
Priority: Critical
Labels: HQL, fetch, hibernate, join
The problem is discussed on the forum a long time ago. I just found the topic and i
wanted to report that this bug is still available in 3.6.6
https://forum.hibernate.org/viewtopic.php?f=1&t=987905&start=0
Here a concrete example from my usecase:
class A{
private B b;
}
class B{
private Map<String, C> map;
}
class C{
private String c;
}
Just imagine that the classes and fields would be annotated right ;)
Now the problem in my case was that i wanted a list of A elements with fetch joined B and
of course it's map.
I tried the following query:
FROM A a LEFT OUTER JOIN FETCH a.b bElem LEFT OUTER JOIN bElem.map cMap
and i got a NullPointerException just like the users which posted in the given topic.
My workaround was:
FROM A a LEFT OUTER JOIN FETCH a.b bElem LEFT OUTER JOIN a.b.map cMap
The main problem now is, that i have a dynamic fetch profile system which won't work
correctly if this issue is not solved.
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira