[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4718?page=c...
]
Gail Badner resolved HHH-4718.
------------------------------
Assignee: Gail Badner
Resolution: Duplicate
Select with subselect operands to a division gives
NullPointerException on BinaryArithmeticOperatorNode
-------------------------------------------------------------------------------------------------------
Key: HHH-4718
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4718
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.7, 3.3.2
Environment: Any
Reporter: Bruno Medeiros
Assignee: Gail Badner
Original Estimate: 24h
Remaining Estimate: 24h
I tried to perform the following query:
---------------------------------------------------------------
select new map(
e as estacao,
(
(
select count(c)
from Chamada c
where 1 = 1
and c.estacao = e
and c.data >= :dataInicial
and c.data <= :dataFinal
)
/
(
select count(c2)
from Chamada c2
where 1 = 1
and c.data >= :dataInicial
and c.data <= :dataFinal
)
) as quantidade
)
from Estacao e
--------------------------------------------------------------
That gives the following atack trace:
--------------------------------------------------------------
Exception in thread "main" java.lang.NullPointerException
at
org.hibernate.hql.ast.tree.BinaryArithmeticOperatorNode.getRightHandOperand(BinaryArithmeticOperatorNode.java:185)
at
org.hibernate.hql.ast.tree.BinaryArithmeticOperatorNode.initialize(BinaryArithmeticOperatorNode.java:20)
at org.hibernate.hql.ast.HqlSqlWalker.prepareArithmeticOperator(HqlSqlWalker.java:1011)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.arithmeticExpr(HqlSqlBaseWalker.java:2783)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExpr(HqlSqlBaseWalker.java:2006)
at
org.hibernate.hql.antlr.HqlSqlBaseWalker.aliasedSelectExpr(HqlSqlBaseWalker.java:2057)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.constructor(HqlSqlBaseWalker.java:2226)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExpr(HqlSqlBaseWalker.java:1952)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExprList(HqlSqlBaseWalker.java:1825)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectClause(HqlSqlBaseWalker.java:1394)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:553)
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)
------------------------------------------------------------------
If I select the operands separately and do the division in Java code the query works
perfectly.
--
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