[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2353) ClassCastException thrown in org.hibernate.hql.ast.HqlSqlWalker.resolve
Yajun Shi (JIRA)
noreply at atlassian.com
Thu Jan 11 14:14:44 EST 2007
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2353?page=comments#action_25783 ]
Yajun Shi commented on HHH-2353:
--------------------------------
Will you post a simple test case?
> ClassCastException thrown in org.hibernate.hql.ast.HqlSqlWalker.resolve
> -----------------------------------------------------------------------
>
> Key: HHH-2353
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2353
> Project: Hibernate3
> Type: Bug
> Versions: 3.2.1, 3.2.0.cr4
> Environment: Currently Hibernate 3.2.1, MySQL 5.0.26, Tomcat 5.5.20, Java 1.5 patch 10
> Reporter: James Andrews
>
>
> Above error thrown when attempting to force a left join fetch in hql on a many-to-many mapping:
> Using 3 tables
> accountgroup
> id INTEGER PRIMARY
> ...
> accountline
> id INTEGER PRIMARY
> ...
> accountgroupmapping
> id INTEGER PRIMARY
> groupId INTEGER
> lineId INTEGER
> ...
> Set mapping in hbm:
> <set name="lines" table="budget.grouplinemap" fetch="join" lazy="false">
> <key column="groupId" not-null="true"></key>
> <many-to-many class="intranet.budget.AccountLine"
> column="lineId" fetch="join" lazy="false">
> </many-to-many>
> </set>
> HQL query executed:
> select group from AccountGroup group left join fetch group.lines
> Result:
> java.lang.ClassCastException: org.hibernate.hql.ast.tree.SqlNode
> at org.hibernate.hql.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:722)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.propertyRef(HqlSqlBaseWalker.java:1105)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.propertyRefLhs(HqlSqlBaseWalker.java:4920)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.propertyRef(HqlSqlBaseWalker.java:1066)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:3198)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3067)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2945)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
> 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:228)
> at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
> at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
> at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
> at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
> at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
> at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
> at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
> at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
> The above works fine if I remove the left join fetch, or if I make the relationship one-to-many, but when I create a many-to-many relationship the error above occurs.
> But since the above is being encoded to an AJAX frontend, and the lines fields are referenced immediately, removing the left join fetch results in N+1 selects despite the fetch="join" and lazy="false" in the .hbm descriptor.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list