java.lang.NullPointerException

Hibernate JIRA | Donatas Ciuksys | 4 years 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

    two entities, Person and PersonInfo, with a one-to-one relation: {code:title=Person.java|borderStyle=solid} @Entity public class Person { @Id private Integer id; @Basic private String name; @OneToOne( cascade = CascadeType.ALL, mappedBy = "id" ) private PersonInfo personInfo; ...getters&setters... } {code} {code:title=PersonInfo.java|borderStyle=solid} @Entity public class PersonInfo { @Id @OneToOne private Person id; @Basic private String info; ...getters&setters... } {code} NPE occours during a simple select query (only if tables have one or more records): em.createQuery("SELECT p FROM Person p").getResultList(); INFO: HHH000397: Using ASTQueryTranslatorFactory java.lang.NullPointerException at org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:2362) at org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:702) at org.hibernate.type.EntityType.resolve(EntityType.java:474) at org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:167) at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:137) at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1103) at org.hibernate.loader.Loader.processResultSet(Loader.java:960) at org.hibernate.loader.Loader.doQuery(Loader.java:910) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341) at org.hibernate.loader.Loader.doList(Loader.java:2516) at org.hibernate.loader.Loader.doList(Loader.java:2502) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2332) at org.hibernate.loader.Loader.list(Loader.java:2327) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:490) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1268) at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101) at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:264) at lt.mitsoft.hibernatebug.App.main(App.java:21)

    Hibernate JIRA | 4 years ago | Donatas Ciuksys
    java.lang.NullPointerException
  2. 0

    two entities, Person and PersonInfo, with a one-to-one relation: {code:title=Person.java|borderStyle=solid} @Entity public class Person { @Id private Integer id; @Basic private String name; @OneToOne( cascade = CascadeType.ALL, mappedBy = "id" ) private PersonInfo personInfo; ...getters&setters... } {code} {code:title=PersonInfo.java|borderStyle=solid} @Entity public class PersonInfo { @Id @OneToOne private Person id; @Basic private String info; ...getters&setters... } {code} NPE occours during a simple select query (only if tables have one or more records): em.createQuery("SELECT p FROM Person p").getResultList(); INFO: HHH000397: Using ASTQueryTranslatorFactory java.lang.NullPointerException at org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:2362) at org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:702) at org.hibernate.type.EntityType.resolve(EntityType.java:474) at org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:167) at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:137) at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1103) at org.hibernate.loader.Loader.processResultSet(Loader.java:960) at org.hibernate.loader.Loader.doQuery(Loader.java:910) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341) at org.hibernate.loader.Loader.doList(Loader.java:2516) at org.hibernate.loader.Loader.doList(Loader.java:2502) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2332) at org.hibernate.loader.Loader.list(Loader.java:2327) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:490) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1268) at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101) at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:264) at lt.mitsoft.hibernatebug.App.main(App.java:21)

    Hibernate JIRA | 4 years ago | Donatas Ciuksys
    java.lang.NullPointerException
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    I've two entities, Person and PersonInfo, with a one-to-one relation: {code:title=Person.java} @Entity public class Person { @Id private Integer id; @Basic private String name; @OneToOne( mappedBy = "id" ) private PersonInfo personInfo; ...getters&setters... } {code} {code:title=PersonInfo.java} @Entity public class PersonInfo { @Id @OneToOne private Person id; @Basic private String info; ...getters&setters... } {code} Hibernate correctly creates two tables but a NPE occours during a simple select query (only if tables have one or more records) em.createQuery("SELECT p FROM Person p").getResultList(); ... java.lang.NullPointerException at org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:2202) at org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:661) at org.hibernate.type.EntityType.resolve(EntityType.java:441) at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:150) at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1006) at org.hibernate.loader.Loader.doQuery(Loader.java:883) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289) at org.hibernate.loader.Loader.doList(Loader.java:2463) at org.hibernate.loader.Loader.doList(Loader.java:2449) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2279) at org.hibernate.loader.Loader.list(Loader.java:2274) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:470) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:196) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1118) at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101) at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:252) at com.sun.enterprise.container.common.impl.QueryWrapper.getResultList(QueryWrapper.java:195) at nogroup.hibertest.Bean.execute(Bean.java:23) at nogroup.hibertest.org$jboss$weld$bean-hibertest-1$0-SNAPSHOT-ManagedBean-class_nogroup$hibertest$Bean_$$_WeldClientProxy.execute(org$jboss$weld$bean-hibertest-1$0-SNAPSHOT-ManagedBean-class_nogroup$hibertest$Bean_$$_WeldClientProxy.java) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at javax.el.BeanELResolver.invokeMethod(BeanELResolver.java:737) at javax.el.BeanELResolver.invoke(BeanELResolver.java:467) at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:254) at com.sun.el.parser.AstValue.invoke(AstValue.java:228) at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297) at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43) at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56) at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) ... 33 more

    Hibernate JIRA | 5 years ago | Alfio
    java.lang.NullPointerException
  5. 0

    I've two entities, Person and PersonInfo, with a one-to-one relation: {code:title=Person.java} @Entity public class Person { @Id private Integer id; @Basic private String name; @OneToOne( mappedBy = "id" ) private PersonInfo personInfo; ...getters&setters... } {code} {code:title=PersonInfo.java} @Entity public class PersonInfo { @Id @OneToOne private Person id; @Basic private String info; ...getters&setters... } {code} Hibernate correctly creates two tables but a NPE occours during a simple select query (only if tables have one or more records) em.createQuery("SELECT p FROM Person p").getResultList(); ... java.lang.NullPointerException at org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:2202) at org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:661) at org.hibernate.type.EntityType.resolve(EntityType.java:441) at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:150) at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1006) at org.hibernate.loader.Loader.doQuery(Loader.java:883) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289) at org.hibernate.loader.Loader.doList(Loader.java:2463) at org.hibernate.loader.Loader.doList(Loader.java:2449) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2279) at org.hibernate.loader.Loader.list(Loader.java:2274) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:470) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:196) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1118) at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101) at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:252) at com.sun.enterprise.container.common.impl.QueryWrapper.getResultList(QueryWrapper.java:195) at nogroup.hibertest.Bean.execute(Bean.java:23) at nogroup.hibertest.org$jboss$weld$bean-hibertest-1$0-SNAPSHOT-ManagedBean-class_nogroup$hibertest$Bean_$$_WeldClientProxy.execute(org$jboss$weld$bean-hibertest-1$0-SNAPSHOT-ManagedBean-class_nogroup$hibertest$Bean_$$_WeldClientProxy.java) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at javax.el.BeanELResolver.invokeMethod(BeanELResolver.java:737) at javax.el.BeanELResolver.invoke(BeanELResolver.java:467) at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:254) at com.sun.el.parser.AstValue.invoke(AstValue.java:228) at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297) at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43) at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56) at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) ... 33 more

    Hibernate JIRA | 5 years ago | Alfio
    java.lang.NullPointerException

    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.persister.entity.AbstractEntityPersister.loadByUniqueKey()
    2. Hibernate
      QueryImpl.list
      1. org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:2362)
      2. org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:702)
      3. org.hibernate.type.EntityType.resolve(EntityType.java:474)
      4. org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:167)
      5. org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:137)
      6. org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1103)
      7. org.hibernate.loader.Loader.processResultSet(Loader.java:960)
      8. org.hibernate.loader.Loader.doQuery(Loader.java:910)
      9. org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341)
      10. org.hibernate.loader.Loader.doList(Loader.java:2516)
      11. org.hibernate.loader.Loader.doList(Loader.java:2502)
      12. org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2332)
      13. org.hibernate.loader.Loader.list(Loader.java:2327)
      14. org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:490)
      15. org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355)
      16. org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195)
      17. org.hibernate.internal.SessionImpl.list(SessionImpl.java:1268)
      18. org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
      18 frames
    3. Hibernate EJB
      QueryImpl.getResultList
      1. org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:264)
      1 frame
    4. lt.mitsoft.hibernatebug
      App.main
      1. lt.mitsoft.hibernatebug.App.main(App.java:21)
      1 frame