org.hibernate.hql.ast.QuerySyntaxException: unexpected token: . near line 1, column 17 [select c.entered.on from eg.domain.Cat c]

Hibernate JIRA | Rhett Sutphin | 1 decade ago
  1. 0

    Hibernate / Mailing Lists

    sourceforge.net | 1 year ago
    org.hibernate.hql.ast.QuerySyntaxException: unexpected token: . near line 1, column 17 [select c.entered.on from eg.domain.Cat c]
  2. 0

    A CompositeUserType property named "on" cannot be dereferenced in an HQL query. Code, mappings, and an HSQL for the following examples is in the attached tarball. That attachment includes a test script that demonstrates the problem. You can run it like so: ant -Dhibernate-path=/path/to/hibernate-3.1 Mapping used: <class name="Cat" table="t_cats"> <id name="id"><generator class="identity"/></id> <property name="name"/> <property name="entered" type="eg.domain.hibernate.AuditInfoType"> <column name="entered_on"/> <column name="entered_by"/> </property> </class> AuditInfoType is a CompositeUserType that defines two properties: on and by. The test fails when it runs the following query: select c.entered.on from Cat c It fails with this exception: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: . near line 1, column 17 [select c.entered.on from eg.domain.Cat c] at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59) at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:244) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:155) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:105) 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:1600) at eg.Main.main(Main.java:33) Caused by: line 1:17: unexpected token: . at org.hibernate.hql.antlr.HqlBaseParser.primaryExpression(HqlBaseParser.java:877) at org.hibernate.hql.antlr.HqlBaseParser.atom(HqlBaseParser.java:3422) at org.hibernate.hql.antlr.HqlBaseParser.unaryExpression(HqlBaseParser.java:3200) at org.hibernate.hql.antlr.HqlBaseParser.multiplyExpression(HqlBaseParser.java:3082) at org.hibernate.hql.antlr.HqlBaseParser.additiveExpression(HqlBaseParser.java:2802) at org.hibernate.hql.antlr.HqlBaseParser.concatenation(HqlBaseParser.java:570) at org.hibernate.hql.antlr.HqlBaseParser.relationalExpression(HqlBaseParser.java:2586) at org.hibernate.hql.antlr.HqlBaseParser.equalityExpression(HqlBaseParser.java:2449) at org.hibernate.hql.antlr.HqlBaseParser.negatedExpression(HqlBaseParser.java:2413) at org.hibernate.hql.antlr.HqlBaseParser.logicalAndExpression(HqlBaseParser.java:2331) at org.hibernate.hql.antlr.HqlBaseParser.logicalOrExpression(HqlBaseParser.java:2296) at org.hibernate.hql.antlr.HqlBaseParser.expression(HqlBaseParser.java:2082) at org.hibernate.hql.antlr.HqlBaseParser.aliasedExpression(HqlBaseParser.java:2249) at org.hibernate.hql.antlr.HqlBaseParser.selectedPropertiesList(HqlBaseParser.java:1455) at org.hibernate.hql.antlr.HqlBaseParser.selectClause(HqlBaseParser.java:1365) at org.hibernate.hql.antlr.HqlBaseParser.selectFrom(HqlBaseParser.java:1106) at org.hibernate.hql.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:702) at org.hibernate.hql.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:296) at org.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:159) at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:238) ... 9 more A similar exception is thrown when entered.on is used in a where clause. Selecting for entered.by works fine, as does loading an entire Cat instance. If you change the name of the "on" property in AuditInfoType, the problem goes away.

    Hibernate JIRA | 1 decade ago | Rhett Sutphin
    org.hibernate.hql.ast.QuerySyntaxException: unexpected token: . near line 1, column 17 [select c.entered.on from eg.domain.Cat c]
  3. 0

    A CompositeUserType property named "on" cannot be dereferenced in an HQL query. Code, mappings, and an HSQL for the following examples is in the attached tarball. That attachment includes a test script that demonstrates the problem. You can run it like so: ant -Dhibernate-path=/path/to/hibernate-3.1 Mapping used: <class name="Cat" table="t_cats"> <id name="id"><generator class="identity"/></id> <property name="name"/> <property name="entered" type="eg.domain.hibernate.AuditInfoType"> <column name="entered_on"/> <column name="entered_by"/> </property> </class> AuditInfoType is a CompositeUserType that defines two properties: on and by. The test fails when it runs the following query: select c.entered.on from Cat c It fails with this exception: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: . near line 1, column 17 [select c.entered.on from eg.domain.Cat c] at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59) at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:244) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:155) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:105) 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:1600) at eg.Main.main(Main.java:33) Caused by: line 1:17: unexpected token: . at org.hibernate.hql.antlr.HqlBaseParser.primaryExpression(HqlBaseParser.java:877) at org.hibernate.hql.antlr.HqlBaseParser.atom(HqlBaseParser.java:3422) at org.hibernate.hql.antlr.HqlBaseParser.unaryExpression(HqlBaseParser.java:3200) at org.hibernate.hql.antlr.HqlBaseParser.multiplyExpression(HqlBaseParser.java:3082) at org.hibernate.hql.antlr.HqlBaseParser.additiveExpression(HqlBaseParser.java:2802) at org.hibernate.hql.antlr.HqlBaseParser.concatenation(HqlBaseParser.java:570) at org.hibernate.hql.antlr.HqlBaseParser.relationalExpression(HqlBaseParser.java:2586) at org.hibernate.hql.antlr.HqlBaseParser.equalityExpression(HqlBaseParser.java:2449) at org.hibernate.hql.antlr.HqlBaseParser.negatedExpression(HqlBaseParser.java:2413) at org.hibernate.hql.antlr.HqlBaseParser.logicalAndExpression(HqlBaseParser.java:2331) at org.hibernate.hql.antlr.HqlBaseParser.logicalOrExpression(HqlBaseParser.java:2296) at org.hibernate.hql.antlr.HqlBaseParser.expression(HqlBaseParser.java:2082) at org.hibernate.hql.antlr.HqlBaseParser.aliasedExpression(HqlBaseParser.java:2249) at org.hibernate.hql.antlr.HqlBaseParser.selectedPropertiesList(HqlBaseParser.java:1455) at org.hibernate.hql.antlr.HqlBaseParser.selectClause(HqlBaseParser.java:1365) at org.hibernate.hql.antlr.HqlBaseParser.selectFrom(HqlBaseParser.java:1106) at org.hibernate.hql.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:702) at org.hibernate.hql.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:296) at org.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:159) at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:238) ... 9 more A similar exception is thrown when entered.on is used in a where clause. Selecting for entered.by works fine, as does loading an entire Cat instance. If you change the name of the "on" property in AuditInfoType, the problem goes away.

    Hibernate JIRA | 1 decade ago | Rhett Sutphin
    org.hibernate.hql.ast.QuerySyntaxException: unexpected token: . near line 1, column 17 [select c.entered.on from eg.domain.Cat c]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    How to use inner join query in hql?

    Stack Overflow | 2 years ago | Akshant poonia
    org.hibernate.hql.ast.QuerySyntaxException: unexpected token: on near line 1, column 74 [select user_name, message from com.csc.project.user e inner join tweet p on p.user_id=e.id where e.user_name=:name]
  6. 0

    Hibernate Community • View topic - Using List in HQL WHERE clause

    hibernate.org | 7 months ago
    org.springframework.orm.hibernate3.HibernateQueryException: expecting IDENT, found ':' near line 1, column 175 [select l from Location as l where l.latitude = :lat and l.longitude = :long and l.category.code in elements(:codes)]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: expecting IDENT, found ':' near line 1, column 175 [select l from Location as l where l.latitude = :lat and l.longitude = :long and l.category.code in elements(:codes)]

    6 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.hibernate.hql.ast.QuerySyntaxException

      unexpected token: . near line 1, column 17 [select c.entered.on from eg.domain.Cat c]

      at org.hibernate.hql.ast.ErrorCounter.throwQueryException()
    2. Hibernate HQL/JP-QL Parser
      QueryTranslatorImpl.compile
      1. org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)
      2. org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:244)
      3. org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:155)
      4. org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:105)
      4 frames
    3. Hibernate
      SessionImpl.createQuery
      1. org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)
      2. org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
      3. org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
      4. org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:134)
      5. org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:113)
      6. org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1600)
      6 frames
    4. FitNesse
      Main.main
      1. eg.Main.main(Main.java:33)
      1 frame