Same exact problem here. I get the same exception when executing a Query.
I have objects mapped like this:
Code:
<class name="myclass.beans.Event" table="events">
<composite-id>
<key-many-to-one name="meeting" class="myclass.beans.Meeting">
<column name="day"/>
<column name="meeting_number"/>
</key-many-to-one>
<key-property name="eventNumber" column="event_number"/>
</composite-id>
</class>
<class name="myclass.beans.Meeting" table="meetings">
<composite-id>
<key-property name="day" column="day"/>
<key-many-to-one name="map" class="myclass.beans.Map" column="meeting_number"/>
</composite-id>
</class>
<class name="myclass.beans.Map" table="track_map">
<id name="meetingNumber" column="meeting_number" type="int">
<generator class="assigned"/>
</id>
<set name="associationAlias" inverse="true" cascade="delete" order-by="association_name" batch-size="10">
<key column="meeting_number"/>
<one-to-many class="myclass.beans.AssociationAlias"/>
</set>
</class>
<class name="myclass.beans.AssociationAlias" table="association_alias">
<composite-id>
<key-many-to-one name="trackMap" class="myclass.beans.Map" column="meeting_number"/>
<key-property name="associationName" column="association_name"/>
</composite-id>
</class>
Then execute a query like this:
Code:
Query q = sess.createQuery("from Event e where e.meeting.day = :day"
+ " and e.meeting.map.associationAlias.code = :name"
+ " and e.eventNumber = :eventNumber");
q.setDate("day", date);
q.setString("name", name);
q.setInteger("eventNumber", eventNumber);
return q.list(); // <--- Throws QueryException
Throws this QueryException using 3.2.3 (but runs just fine using 3.2.2):
Code:
org.hibernate.QueryException: illegal attempt to dereference collection [(event0_.day, event0_.meeting_number, event0_.event_number)(event0_.day, event0_.meeting_number)meetingmeetin1_.meeting_numbermap.associationAlias] with element property reference [associationName] [from myclass.beans.Event e where e.meeting.raceday = :raceday and e.meeting.map.associationAlias.associationName = :name and e.eventNumber = :eventNumber]
at org.hibernate.hql.ast.tree.DotNode$1.buildIllegalCollectionDereferenceException(DotNode.java:46)
at org.hibernate.hql.ast.tree.DotNode.checkLhsIsNotCollection(DotNode.java:512)
at org.hibernate.hql.ast.tree.DotNode.resolve(DotNode.java:221)
at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:94)
at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:90)
at org.hibernate.hql.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:728)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1216)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4041)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3525)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1762)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1690)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1687)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577)
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)
at myclass.util.HibernateUtil.getEventByAssociationName(HibernateUtil.java:1469)