HQL: elements() requires an alias to work?
------------------------------------------
Key: HHH-2565
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2565
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.0.5
Environment: Hibernate 3.0.5 (sorry, I can't check to see if the bug is still
in any later version)
Reporter: tenwit
Priority: Minor
I'm using a simple named query to search for all objects that have a given
value-element in a set. It works if I alias the object, but not if I don't. In the
code below, query OrganisationsByType1 produces the given exception, OrganisationsByType2
works perfectly.
Mapping documents:<pre>
<class name="OrganisationImpl" table="Organisation">
...
<set name="Types" table="OrganisationTypeLink"
lazy="true" cascade="all">
<key column="OrganisationID"/>
<element column="OrganisationTypeID" not-null="true"
type="OrganisationType"/>
</set>
</class>
<query name="OrganisationsByType1">
from OrganisationImpl
where :Type in elements(Types)
</query>
<query name="OrganisationsByType2">
from OrganisationImpl o
where :Type in elements(o.Types)
</query>
</pre>
Full stack trace of any exception that occurs:
<pre>java.lang.NullPointerException
at org.hibernate.hql.ast.MethodNode.handleElements(MethodNode.java:154)
at org.hibernate.hql.ast.MethodNode.resolveCollectionProperty(MethodNode.java:105)
at org.hibernate.hql.ast.CollectionFunction.resolve(CollectionFunction.java:22)
at org.hibernate.hql.ast.HqlSqlWalker.processFunction(HqlSqlWalker.java:538)
at
org.hibernate.hql.antlr.HqlSqlBaseWalker.collectionFunction(HqlSqlBaseWalker.java:2273)
at
org.hibernate.hql.antlr.HqlSqlBaseWalker.collectionFunctionOrSubselect(HqlSqlBaseWalker.java:3937)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.inRhs(HqlSqlBaseWalker.java:3854)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3517)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1405)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1333)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:599)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:404)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:201)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:151)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427)
at
org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:388)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:291)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
</pre>...
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira