Vasant created Bug HHH-7422
Issue Type: Bug Bug
Affects Versions: 3.6.1
Assignee: Unassigned
Components: core, query-hql, query-sql
Created: 28/Jun/12 10:00 AM
Description:

Below HQL fail to parse with the new parser i.e. ASTQueryTranslatorFactory introduced in Hibernate-3.6.1.

HQL
------------------------------------------------------------------------------

<![CDATA[,ParameterValue a,ParameterValue b,ParameterValue c,ParameterValue d,ParameterValue e,ParameterValue f,ParameterValue g,ParameterValue h where device.cachedDataRecord =ALL(a.dataRecord,b.dataRecord,c.dataRecord,d.dataRecord,e.dataRecord,f.dataRecord,g.dataRecord,h.dataRecord) and a.parameterValueName='Device.Services.BSR.1.latitude.degrees' and b.parameterValueName='Device.Services.BSR.1.latitude.minutes' and c.parameterValueName='Device.Services.BSR.1.latitude.seconds' and d.parameterValueName='Device.Services.BSR.1.latitude.hemisphere'and e.parameterValueName='Device.Services.BSR.1.longitude.degrees' and f.parameterValueName='Device.Services.BSR.1.longitude.minutes' and g.parameterValueName='Device.Services.BSR.1.longitude.seconds' and h.parameterValueName='Device.Services.BSR.1.longitude.hemisphere' and lower(d.stringValue) IN (lower(substr(:sA,10)),lower(substr(:eA,10))) and lower(h.stringValue) IN (lower(substr(:sO,11)),lower(substr(:eO,11))) and ((3600*a.integerValue)+(60*b.integerValue)+c.integerValue)>=(case when lower(d.stringValue)=ALL(lower(substr(:sA,10)),lower(substr(:eA,10))) then ((3600*substr(:sA,1,2))+(60*substr(:sA,4,2))+substr(:sA,7,2)) else 0 end) and ((3600*a.integerValue)+(60*b.integerValue)+c.integerValue)<=(case when (lower(d.stringValue)=lower(substr(:sA,10)) and lower(d.stringValue)!=lower(substr(:eA,10))) then ((3600*substr(:sA,1,2))+(60*substr(:sA,4,2))+substr(:sA,7,2)) else ((3600*substr(:eA,1,2))+(60*substr(:eA,4,2))+substr(:eA,7,2)) end) and ((3600*e.integerValue)+(60*f.integerValue)+g.integerValue)>=(case when lower(h.stringValue)=ALL(lower(substr(:sO,11)),lower(substr(:eO,11))) then ((3600*substr(:sO,1,3))+(60*substr(:sO,5,2))+substr(:sO,8,2)) else 0 end) and ((3600*e.integerValue)+(60*f.integerValue)+g.integerValue)<=(case when(lower(h.stringValue)=lower(substr(:sO,11)) and lower(h.stringValue)!=lower(substr(:eO,11))) then ((3600*substr(:sO,1,3))+(60*substr(:sO,5,2))+substr(:sO,8,2)) else ((3600*substr(:eO,1,3))+(60*substr(:eO,5,2))+substr(:eO,8,2)) end)]]>
----------------------------------------------------------------------------

Error message from Hibernate:
----------------------------------------------------------------------------
2012-06-05 14:59:14,841|ERROR|hdm |Thread-2180 |org.hibernate.hql.PARSER|line 1:483: unexpected token: a
2012-06-05 14:59:14,845|ERROR|hdm |Thread-2180 |org.hibernate.hql.PARSER|line 1:1373: unexpected token: lower
2012-06-05 14:59:14,845|ERROR|hdm |Thread-2180 |org.hibernate.hql.PARSER|line 1:1393: expecting "then", found ')'
2012-06-05 14:59:14,848|ERROR|hdm |Thread-2180 |org.hibernate.hql.PARSER|line 1:1904: unexpected token: lower
2012-06-05 14:59:14,849|ERROR|hdm |Thread-2180 |org.hibernate.hql.PARSER|line 1:1924: expecting "then", found ')'

Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: a near line 1, column 483 [select distinct device.id from motive.hdm.service.device.Device device,motive.hdm.service.devicedata.ParameterValue a,motive.hdm.service.devicedata.ParameterValue b,motive.hdm.service.devicedata.ParameterValue c,motive.hdm.service.devicedata.ParameterValue d,motive.hdm.service.devicedata.ParameterValue e,motive.hdm.service.devicedata.ParameterValue f,motive.hdm.service.devicedata.ParameterValue g,motive.hdm.service.devicedata.ParameterValue h where device.cachedDataRecord =ALL(a.dataRecord,b.dataRecord,c.dataRecord,d.dataRecord,e.dataRecord,f.dataRecord,g.dataRecord,h.dataRecord) and a.parameterValueName='Device.Services.BSR.1.latitude.degrees' and b.parameterValueName='Device.Services.BSR.1.latitude.minutes' and c.parameterValueName='Device.Services.BSR.1.latitude.seconds' and d.parameterValueName='Device.Services.BSR.1.latitude.hemisphere'and e.parameterValueName='Device.Services.BSR.1.longitude.degrees' and f.parameterValueName='Device.Services.BSR.1.longitude.minutes' and g.parameterValueName='Device.Services.BSR.1.longitude.seconds' and h.parameterValueName='Device.Services.BSR.1.longitude.hemisphere' and lower(d.stringValue) IN (lower(substr(:sA,10)),lower(substr(:eA,10))) and lower(h.stringValue) IN (lower(substr(:sO,11)),lower(substr(:eO,11))) and ((3600*a.integerValue)+(60*b.integerValue)+c.integerValue)>=(case when lower(d.stringValue)=ALL(lower(substr(:sA,10)),lower(substr(:eA,10))) then ((3600*substr(:sA,1,2))+(60*substr(:sA,4,2))+substr(:sA,7,2)) else 0 end) and ((3600*a.integerValue)+(60*b.integerValue)+c.integerValue)<=(case when (lower(d.stringValue)=lower(substr(:sA,10)) and lower(d.stringValue)!=lower(substr(:eA,10))) then ((3600*substr(:sA,1,2))+(60*substr(:sA,4,2))+substr(:sA,7,2)) else ((3600*substr(:eA,1,2))+(60*substr(:eA,4,2))+substr(:eA,7,2)) end) and ((3600*e.integerValue)+(60*f.integerValue)+g.integerValue)>=(case when lower(h.stringValue)=ALL(lower(substr(:sO,11)),lower(substr(:eO,11))) then ((3600*substr(:sO,1,3))+(60*substr(:sO,5,2))+substr(:sO,8,2)) else 0 end) and ((3600*e.integerValue)+(60*f.integerValue)+g.integerValue)<=(case when(lower(h.stringValue)=lower(substr(:sO,11)) and lower(h.stringValue)!=lower(substr(:eO,11))) then ((3600*substr(:sO,1,3))+(60*substr(:sO,5,2))+substr(:sO,8,2)) else ((3600*substr(:eO,1,3))+(60*substr(:eO,5,2))+substr(:eO,8,2)) end) and device.deleted=0 order by device.id]
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:54)
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:47)
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:82)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:284)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:182)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
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:124)
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:1770)
at sun.reflect.GeneratedMethodAccessor753.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.orm.hibernate3.HibernateTemplate$CloseSuppressingInvocationHandler.invoke(HibernateTemplate.java:1282)
at $Proxy239.createQuery(Unknown Source)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
... 76 more

----------------------------------------------------------------------------

However same works fine when used "ClassicQueryTranslatorFactory" with Hibernate-3.6.1.

But we want to use the new parser instead of old Classic parser. Can you please check is this an issue with new parser in Hibernate-3.6.1.
And we can't update Hibernate to 4.x for now.
If it has been fixed in Hibernate-4.x then can you please share patch which works with Hibernate-3.6.1.

Environment: Hibernate-3.6.1, Oracle11g, Weblogic11g and using Oracle10gDialect
Project: Hibernate ORM
Priority: Critical Critical
Reporter: Vasant
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira