org.hibernate.hql.ParsingException: HQL000002: The query SELECT p FROM PPPoESession p where p.sourceIP=:source_ip and p.login>:logentrytime and p.logout>:logentrytime OR p.logout IS NULL is not valid; Parser error messages: [[statement, statementElement, selectStatement, queryExpression, querySpec, whereClause, logicalExpression, expression, logicalOrExpression, logicalAndExpression, negatedExpression, equalityExpression]: line 1:144 state 0 (decision=51) no viable alt; token=[@51,144:147='NULL',<75>,1:144]].

Hibernate JIRA | Vinod Kumar Devi | 10 months ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    I am using Hibernate OGM 5.0.1 with MongoDB 3.2.6. My JPA QL is below: String checkquery = "SELECT p FROM pppoe_test p where p.sourceIP=:source_ip and p.login>:logentrytime and (p.logout>:logentrytime OR p.logout IS NULL)"; I get an error like: no viable alternative at input 'NULL' HQL000002: The query SELECT p FROM PPPoESession p where p.sourceIP=:source_ip and p.login>:logentrytime and (p.logout>:logentrytime OR p.logout IS NULL) is not valid Exception in thread "main" org.hibernate.hql.ParsingException: HQL000002: The query SELECT p FROM PPPoESession p where p.sourceIP=:source_ip and p.login>:logentrytime and p.logout>:logentrytime OR p.logout IS NULL is not valid; Parser error messages: [[statement, statementElement, selectStatement, queryExpression, querySpec, whereClause, logicalExpression, expression, logicalOrExpression, logicalAndExpression, negatedExpression, equalityExpression]: line 1:144 state 0 (decision=51) no viable alt; token=[@51,144:147='NULL',<75>,1:144]]. at org.hibernate.hql.QueryParser.parseQuery(QueryParser.java:70) at org.hibernate.ogm.datastore.mongodb.query.parsing.impl.MongoDBBasedQueryParserService.parseQuery(MongoDBBasedQueryParserService.java:40) at org.hibernate.ogm.query.impl.OgmQueryTranslator.getQuery(OgmQueryTranslator.java:169) at org.hibernate.ogm.query.impl.OgmQueryTranslator.getLoader(OgmQueryTranslator.java:134) at org.hibernate.ogm.query.impl.OgmQueryTranslator.list(OgmQueryTranslator.java:128) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1326) at org.hibernate.internal.QueryImpl.list(QueryImpl.java:87) at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:606) at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:483) Here is the mongodb doc, that I had earlier inserted via the OGM. { "_id" : "cc88a708-c222-4e52-b151-c0f40556b27e", "connectionTimeInSeconds" : NumberLong(100), "location" : "MyCastle", "datatransferIn" : NumberLong(7777777), "sourceIP" : "172.168.10.123", "packetsOut" : NumberLong(33333), "login" : ISODate("2016-07-09T20:45:36.492Z"), "logout" : null, "user" : "dvinod@xyz.com", "packetsIn" : NumberLong(22222), "datatransferOut" : NumberLong(5555555) } I do have the attributes setup properly in the entity @Entity (name="pppoe_test") public class PPPoESession { ... @Temporal(TemporalType.TIMESTAMP) private Date logout; @Basic(optional = false) private String user; @Basic(optional = false) private String sourceIP;

    Hibernate JIRA | 10 months ago | Vinod Kumar Devi
    org.hibernate.hql.ParsingException: HQL000002: The query SELECT p FROM PPPoESession p where p.sourceIP=:source_ip and p.login>:logentrytime and p.logout>:logentrytime OR p.logout IS NULL is not valid; Parser error messages: [[statement, statementElement, selectStatement, queryExpression, querySpec, whereClause, logicalExpression, expression, logicalOrExpression, logicalAndExpression, negatedExpression, equalityExpression]: line 1:144 state 0 (decision=51) no viable alt; token=[@51,144:147='NULL',<75>,1:144]].
  2. 0

    JPA QL issue with IS NULL filter for MongoDB in Hibernate OGM

    Stack Overflow | 10 months ago | Vinod
    org.hibernate.hql.ParsingException: HQL000002: The query SELECT p FROM PPPoESession p where p.sourceIP=:source_ip and p.login>:logentrytime and p.logout>:logentrytime OR p.logout IS NULL is not valid; Parser error messages: [[statement, statementElement, selectStatement, queryExpression, querySpec, whereClause, logicalExpression, expression, logicalOrExpression, logicalAndExpression, negatedExpression, equalityExpression]: line 1:144 state 0 (decision=51) no viable alt; token=[@51,144:147='NULL',<75>,1:144]].
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.hibernate.hql.ParsingException

      HQL000002: The query SELECT p FROM PPPoESession p where p.sourceIP=:source_ip and p.login>:logentrytime and p.logout>:logentrytime OR p.logout IS NULL is not valid; Parser error messages: [[statement, statementElement, selectStatement, queryExpression, querySpec, whereClause, logicalExpression, expression, logicalOrExpression, logicalAndExpression, negatedExpression, equalityExpression]: line 1:144 state 0 (decision=51) no viable alt; token=[@51,144:147='NULL',<75>,1:144]].

      at org.hibernate.hql.QueryParser.parseQuery()
    2. Hibernate HQL/JP-QL Parser
      QueryParser.parseQuery
      1. org.hibernate.hql.QueryParser.parseQuery(QueryParser.java:70)
      1 frame
    3. org.hibernate.ogm
      MongoDBBasedQueryParserService.parseQuery
      1. org.hibernate.ogm.datastore.mongodb.query.parsing.impl.MongoDBBasedQueryParserService.parseQuery(MongoDBBasedQueryParserService.java:40)
      1 frame
    4. Hibernate Object Grid Mapper
      OgmQueryTranslator.list
      1. org.hibernate.ogm.query.impl.OgmQueryTranslator.getQuery(OgmQueryTranslator.java:169)
      2. org.hibernate.ogm.query.impl.OgmQueryTranslator.getLoader(OgmQueryTranslator.java:134)
      3. org.hibernate.ogm.query.impl.OgmQueryTranslator.list(OgmQueryTranslator.java:128)
      3 frames
    5. Hibernate
      QueryImpl.list
      1. org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216)
      2. org.hibernate.internal.SessionImpl.list(SessionImpl.java:1326)
      3. org.hibernate.internal.QueryImpl.list(QueryImpl.java:87)
      3 frames
    6. org.hibernate.jpa
      QueryImpl.getResultList
      1. org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:606)
      2. org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:483)
      2 frames