java.lang.NullPointerException

Hibernate JIRA | Antonio Anzivino | 6 months ago
  1. 0

    I am reporting this as a bug because Hibernate does not explain me what is wrong with my HQL syntax and instead leaves a NPE in the wild. I found that my syntax contains a trivial error (not referencing properties of associated ManyToOne eager relationship) h1. Input Wrong HQL is {code:java} select sum(item.importo) from Movimento item where ((organizationId in ( ?0 )) and ?1 in elements(associatedUsers) and (dataValuta < ?2)) {code} Correct HQL is {code:java} select sum(item.importo) from Movimento item where ((contoCorrente.organizationId in ( ?0 )) and ?1 in elements(contoCorrente.associatedUsers) and (dataValuta < ?2)) {code} Movimento class properties: - contoCorrente: POJO ContoCorrente @ManyToOne - dataValuta: java.util.Date ContoCorrente properties: - organizationId: string - associatedUsers: Set<String> h1. Exception {code:java} java.lang.NullPointerException at org.hibernate.hql.internal.ast.tree.MethodNode.handleElements(MethodNode.java:194) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.ast.tree.MethodNode.resolveCollectionProperty(MethodNode.java:147) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.ast.tree.CollectionFunction.resolve(CollectionFunction.java:26) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.ast.HqlSqlWalker.processFunction(HqlSqlWalker.java:1145) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.collectionFunction(HqlSqlBaseWalker.java:3025) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.collectionFunctionOrSubselect(HqlSqlBaseWalker.java:4924) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.inRhs(HqlSqlBaseWalker.java:4833) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:4500) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2130) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2058) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2055) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:813) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:607) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:311) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:259) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:262) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:190) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:142) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:115) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:76) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:150) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:302) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:240) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1907) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at it.csttech.regia.data.daos.hibernate.MovimentoDaoImpl.sumAllImporti(MovimentoDaoImpl.java:22) ~[classes/:?] {code} h1. Expected result An exception that tells there is no such property "organizationId" in class Movimento (because it is a property of movimento.contoCorrente relationship) ----- I propose this suitable for new contributors because I deem such NPE handling very easy to address

    Hibernate JIRA | 6 months ago | Antonio Anzivino
    java.lang.NullPointerException
  2. 0

    I am reporting this as a bug because Hibernate does not explain me what is wrong with my HQL syntax and instead leaves a NPE in the wild. I found that my syntax contains a trivial error (not referencing properties of associated ManyToOne eager relationship) h1. Input Wrong HQL is {code:java} select sum(item.importo) from Movimento item where ((organizationId in ( ?0 )) and ?1 in elements(associatedUsers) and (dataValuta < ?2)) {code} Correct HQL is {code:java} select sum(item.importo) from Movimento item where ((contoCorrente.organizationId in ( ?0 )) and ?1 in elements(contoCorrente.associatedUsers) and (dataValuta < ?2)) {code} Movimento class properties: - contoCorrente: POJO ContoCorrente @ManyToOne - dataValuta: java.util.Date ContoCorrente properties: - organizationId: string - associatedUsers: Set<String> h1. Exception {code:java} java.lang.NullPointerException at org.hibernate.hql.internal.ast.tree.MethodNode.handleElements(MethodNode.java:194) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.ast.tree.MethodNode.resolveCollectionProperty(MethodNode.java:147) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.ast.tree.CollectionFunction.resolve(CollectionFunction.java:26) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.ast.HqlSqlWalker.processFunction(HqlSqlWalker.java:1145) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.collectionFunction(HqlSqlBaseWalker.java:3025) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.collectionFunctionOrSubselect(HqlSqlBaseWalker.java:4924) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.inRhs(HqlSqlBaseWalker.java:4833) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:4500) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2130) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2058) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2055) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:813) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:607) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:311) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:259) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:262) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:190) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:142) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:115) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:76) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:150) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:302) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:240) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1907) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at it.csttech.regia.data.daos.hibernate.MovimentoDaoImpl.sumAllImporti(MovimentoDaoImpl.java:22) ~[classes/:?] {code} h1. Expected result An exception that tells there is no such property "organizationId" in class Movimento (because it is a property of movimento.contoCorrente relationship) ----- I propose this suitable for new contributors because I deem such NPE handling very easy to address

    Hibernate JIRA | 6 months ago | Antonio Anzivino
    java.lang.NullPointerException
  3. 0

    Support for summing Joda Money

    GitHub | 3 years ago | martypitt
    java.lang.NullPointerException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    tochar alias problem in h2 1.3.175 version

    Google Groups | 3 years ago | Ram
    java.lang.NullPointerException
  6. 0

    h2 database to_char alias throwing null pointer

    Stack Overflow | 3 years ago | user3443892
    java.lang.NullPointerException

    4 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. java.lang.NullPointerException

      No message provided

      at org.hibernate.hql.internal.ast.tree.MethodNode.handleElements()
    2. Hibernate
      SessionImpl.createQuery
      1. org.hibernate.hql.internal.ast.tree.MethodNode.handleElements(MethodNode.java:194)[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
      2. org.hibernate.hql.internal.ast.tree.MethodNode.resolveCollectionProperty(MethodNode.java:147)[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
      3. org.hibernate.hql.internal.ast.tree.CollectionFunction.resolve(CollectionFunction.java:26)[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
      4. org.hibernate.hql.internal.ast.HqlSqlWalker.processFunction(HqlSqlWalker.java:1145)[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
      5. org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.collectionFunction(HqlSqlBaseWalker.java:3025)[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
      6. org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.collectionFunctionOrSubselect(HqlSqlBaseWalker.java:4924)[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
      7. org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.inRhs(HqlSqlBaseWalker.java:4833)[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
      8. org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:4500)[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
      9. org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2130)[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
      10. org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2058)[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
      11. org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2055)[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
      12. org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:813)[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
      13. org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:607)[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
      14. org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:311)[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
      15. org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:259)[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
      16. org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:262)[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
      17. org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:190)[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
      18. org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:142)[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
      19. org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:115)[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
      20. org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:76)[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
      21. org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:150)[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
      22. org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:302)[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
      23. org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:240)[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
      24. org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1907)[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
      24 frames
    3. it.csttech.regia
      MovimentoDaoImpl.sumAllImporti
      1. it.csttech.regia.data.daos.hibernate.MovimentoDaoImpl.sumAllImporti(MovimentoDaoImpl.java:22)[classes/:?]
      1 frame