If you define a named HQL query
@javax.persistence.NamedQuery (name = "Position.getByProperties", query = "select var from T_POSITION var WHERE var.properties = 0")
the parsing of this HQL query will fail and application will not start.
04.01.2017 10:48:23.559 ERROR [ErrorCounter] line 1:72: unexpected token: var
line 1:72: unexpected token: var
at org.hibernate.hql.internal.antlr.HqlBaseParser.primaryExpression(HqlBaseParser.java:991)
at org.hibernate.hql.internal.antlr.HqlBaseParser.atom(HqlBaseParser.java:3493)
at org.hibernate.hql.internal.antlr.HqlBaseParser.unaryExpression(HqlBaseParser.java:3271)
at org.hibernate.hql.internal.antlr.HqlBaseParser.multiplyExpression(HqlBaseParser.java:3143)
at org.hibernate.hql.internal.antlr.HqlBaseParser.additiveExpression(HqlBaseParser.java:2848)
at org.hibernate.hql.internal.antlr.HqlBaseParser.concatenation(HqlBaseParser.java:590)
at org.hibernate.hql.internal.antlr.HqlBaseParser.relationalExpression(HqlBaseParser.java:2614)
at org.hibernate.hql.internal.antlr.HqlBaseParser.equalityExpression(HqlBaseParser.java:2475)
at org.hibernate.hql.internal.antlr.HqlBaseParser.negatedExpression(HqlBaseParser.java:2439)
at org.hibernate.hql.internal.antlr.HqlBaseParser.logicalAndExpression(HqlBaseParser.java:2355)
at org.hibernate.hql.internal.antlr.HqlBaseParser.logicalOrExpression(HqlBaseParser.java:2320)
at org.hibernate.hql.internal.antlr.HqlBaseParser.expression(HqlBaseParser.java:2030)
at org.hibernate.hql.internal.antlr.HqlBaseParser.logicalExpression(HqlBaseParser.java:1806)
at org.hibernate.hql.internal.antlr.HqlBaseParser.whereClause(HqlBaseParser.java:474)
at org.hibernate.hql.internal.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:730)
at org.hibernate.hql.internal.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:316)
at org.hibernate.hql.internal.antlr.HqlBaseParser.statement(HqlBaseParser.java:179)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:268)
04.01.2017 10:48:23.623 ERROR [SessionFactoryImpl] HHH000177: Error in named query: Position.getByProperties
org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: var near line 1, column 72 [select var from PositionJpaImpl var WHERE var.properties = 0]
at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:54)
at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:47)
at org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:79)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:278)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:182)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:138)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:104)
Taking a look at the ANTLR hql.g file I expect that this problem also occurs in most recent Hibernate 5 versions (though I haven't tested it). |