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; |