[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3715) NPE in HqlSqlWalker, if named parameter contains a "."

Andreas Sahlbach (JIRA) noreply at atlassian.com
Thu Jan 15 09:10:38 EST 2009


NPE in HqlSqlWalker, if named parameter contains a "."
------------------------------------------------------

                 Key: HHH-3715
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3715
             Project: Hibernate Core
          Issue Type: Bug
          Components: query-hql
    Affects Versions: 3.3.1
            Reporter: Andreas Sahlbach
            Priority: Minor


Query used: 

select company from example.PersistentCompany as company join company.attributes as attr where attr.value like :id.krias

With this query I got a NullPointerException in HqlSqlWalker (see Stacktrace below). After some debugging I changed my query to

select company from example.PersistentCompany as company join company.attributes as attr where attr.value like :krias

which works perfectly. I guess the parser misinterpretes the "." in the parametername as tries to resolve a "krias" property. The NPE 
occurs, because there is no "next sibling" for the "krias" node.

I suggest to harden your code against such a parameter name. Error would be ok, if "." in parameter names are not allowed, but there should be no NPE which gives no real hint about the cause.

Stacktrace:
	  at org.hibernate.hql.ast.HqlSqlWalker.lookupProperty(HqlSqlWalker.java:466)
	  at org.hibernate.hql.antlr.HqlSqlBaseWalker.addrExpr(HqlSqlBaseWalker.java:4.326)
	  at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1.212)
	  at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3.672)
	  at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1.762)
	  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:251)
	  at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:183)
	  at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:134)
	  at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
	  at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
	  at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)
	  at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
	  at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
	  at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1.650)
         [...my classes from here on]

-- 
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