unexpected AST node from where (id1,id2) in ((1,2), (3,4))

Description

ANSI SQL allows: WHERE ((id1, id2)) IN ((1,2), (3,4)); but the HQL parser throws org.hibernate.hql.ast.QuerySyntaxException (see stack trace below). I've fixed this by modifying hql.g and sql-gen.g (attached below). Note that these mods caused a NullPointerException due to use of LA(0) in weakKeywords() (see HHH-1885) that I worked around by adding LT(0) != null
before the LA(0) call; however, this does NOT fix the underlying problem [the use of LA(0)]

org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: {vector} [select new com.timestock.tess.data.objects.StatsAggregationData(b.id,b.user,b.transet,b.tranunit,b.userGroup,b.transetGroup,...) from com.timestock.tess.data.objects.StatsTranSetUserGroupInterval b where b.intervalStartTime >= :startTime and b.intervalStartTime < :endTime and (b.transet,b.userGroup) in ((0,0),(600000000000000030,600000000000000137))
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)
at org.hibernate.hql.ast.QueryTranslatorImpl.generate(QueryTranslatorImpl.java:209)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:178)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:109)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:134)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:113)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1602)
at com.timestock.tess.util.StatisticsAggregation.getDatabaseRows(StatisticsAggregation.java:410)
at com.timestock.tess.util.StatisticsAggregation.getDatabaseRows(StatisticsAggregation.java:334)
at com.timestock.tess.util.StatisticsAggregation.getAggregatedRows(StatisticsAggregation.java:222)
at com.timestock.tess.util.TranSetAggregation.AggregateGroup(TranSetAggregation.java:259)
at com.timestock.tess.util.TranSetAggregation.AggregateGroupHourly(TranSetAggregation.java:69)
at com.timestock.tess.services.processors.StatsProcessor.doIntervalAggregation(StatsProcessor.java:732)
at com.timestock.tess.services.processors.StatsProcessor.doIntervalAggregations(StatsProcessor.java:705)
at com.timestock.tess.services.processors.StatsProcessor.processStats(StatsProcessor.java:418)
at com.timestock.tess.services.collectors.StatsCollector$StatisticsCollector.run(StatsCollector.java:559)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
Caused by: <AST>:0:0: unexpected AST node: {vector}
at org.hibernate.hql.antlr.SqlGeneratorBase.inList(SqlGeneratorBase.java:3016)
at org.hibernate.hql.antlr.SqlGeneratorBase.exoticComparisonExpression(SqlGeneratorBase.java:2831)
at org.hibernate.hql.antlr.SqlGeneratorBase.comparisonExpr(SqlGeneratorBase.java:1203)
at org.hibernate.hql.antlr.SqlGeneratorBase.booleanExpr(SqlGeneratorBase.java:851)
at org.hibernate.hql.antlr.SqlGeneratorBase.booleanOp(SqlGeneratorBase.java:2541)
at org.hibernate.hql.antlr.SqlGeneratorBase.booleanExpr(SqlGeneratorBase.java:831)
at org.hibernate.hql.antlr.SqlGeneratorBase.whereExpr(SqlGeneratorBase.java:724)
at org.hibernate.hql.antlr.SqlGeneratorBase.selectStatement(SqlGeneratorBase.java:184)
at org.hibernate.hql.antlr.SqlGeneratorBase.statement(SqlGeneratorBase.java:117)
at org.hibernate.hql.ast.QueryTranslatorImpl.generate(QueryTranslatorImpl.java:203)
... 19 more

Environment

Hibernate 3.1.2 Postgres 8.1.2

Activity

Show:
Brett Meyer
December 18, 2013, 8:28 PM

If this is still an issue on ORM 4.2 or 4.3, anyone have a test case to attach?

Brett Meyer
December 19, 2013, 10:31 PM

Note: In an attempt to clean up the HHH JIRA, we will be rejecting any ticket that sits in the "Awaiting Test Case" state for 2-3 months with no response. So, if this issue is critical to you, please attach a reproducing test case ASAP. Thanks!

Iuliana Cosmina
January 7, 2014, 9:57 AM

Hi,
This issue might be related to this one HHH-7407 and might be just a Hql syntax matter.

Brett Meyer
April 7, 2014, 5:43 PM

In an effort to clean up, in bulk, tickets that are most likely out of date, we're transitioning all ORM 3 tickets to an "Awaiting Test Case" state. Please see http://in.relation.to/Bloggers/HibernateORMJIRAPoliciesAndCleanUpTactics for more information.

If this is still a legitimate bug in ORM 4, please provide either a test case that reproduces it or enough detail (entities, mappings, snippets, etc.) to show that it still fails on 4. If nothing is received within 3 months or so, we'll be automatically closing them.

Thank you!

Brett Meyer
July 8, 2014, 3:11 PM

Bulk rejecting stale issues. If this is still a legitimate issue on ORM 4, feel free to comment and attach a test case. I'll address responses case-by-case. Thanks!

Rejected

Assignee

Unassigned

Reporter

Brian Cox

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure