java.lang.NullPointerException

Hibernate JIRA | Peter Halicky | 3 years ago
  1. 0

    I'm using MapJoin like this: {code:java} CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Data> cq = cb.createQuery(TxData.class); Root<Data> obj = cq.from(Data.class); cq.select(obj); MapJoin<Data, String, OtherClass> mj = obj.joinMap("other"); Path<String> otherKey = mj.key(); Path<OtherClass> otherItem = mj.get("item"); cq.where(cb.and( cb.equal(otherKey,"key"), cb.equal(otherItem , "value"))); TypedQuery<Data> tq = em.createQuery(cq); {code} The em.createQuery(cq) call throws a NullPointerException: {code} java.lang.NullPointerException at org.hibernate.jpa.criteria.path.AbstractPathImpl.getPathIdentifier(AbstractPathImpl.java:92) at org.hibernate.jpa.criteria.path.AbstractPathImpl.render(AbstractPathImpl.java:252) at org.hibernate.jpa.criteria.predicate.ComparisonPredicate.render(ComparisonPredicate.java:187) at org.hibernate.jpa.criteria.predicate.AbstractSimplePredicate.render(AbstractSimplePredicate.java:65) at org.hibernate.jpa.criteria.predicate.CompoundPredicate.render(CompoundPredicate.java:186) at org.hibernate.jpa.criteria.predicate.CompoundPredicate.render(CompoundPredicate.java:132) at org.hibernate.jpa.criteria.predicate.CompoundPredicate.render(CompoundPredicate.java:122) at org.hibernate.jpa.criteria.QueryStructure.render(QueryStructure.java:262) at org.hibernate.jpa.criteria.CriteriaQueryImpl.interpret(CriteriaQueryImpl.java:312) at org.hibernate.jpa.criteria.compile.CriteriaCompiler.compile(CriteriaCompiler.java:147) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:736) {code} The same code works fine on EclipseLink. Seems that the problem is in the MapKeyHelpers.MapKeySource constructor, which calls the super constructor from AbstractPathSource with a null pathSource argument: {code:java} super( criteriaBuilder, javaType, null ); {code} This way, the pathSource is initialized to null. Then, AbstractPathSource's getPathIdentifier() will always throw a NPE.

    Hibernate JIRA | 3 years ago | Peter Halicky
    java.lang.NullPointerException
  2. 0

    I'm using MapJoin like this: {code:java} CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Data> cq = cb.createQuery(TxData.class); Root<Data> obj = cq.from(Data.class); cq.select(obj); MapJoin<Data, String, OtherClass> mj = obj.joinMap("other"); Path<String> otherKey = mj.key(); Path<OtherClass> otherItem = mj.get("item"); cq.where(cb.and( cb.equal(otherKey,"key"), cb.equal(otherItem , "value"))); TypedQuery<Data> tq = em.createQuery(cq); {code} The em.createQuery(cq) call throws a NullPointerException: {code} java.lang.NullPointerException at org.hibernate.jpa.criteria.path.AbstractPathImpl.getPathIdentifier(AbstractPathImpl.java:92) at org.hibernate.jpa.criteria.path.AbstractPathImpl.render(AbstractPathImpl.java:252) at org.hibernate.jpa.criteria.predicate.ComparisonPredicate.render(ComparisonPredicate.java:187) at org.hibernate.jpa.criteria.predicate.AbstractSimplePredicate.render(AbstractSimplePredicate.java:65) at org.hibernate.jpa.criteria.predicate.CompoundPredicate.render(CompoundPredicate.java:186) at org.hibernate.jpa.criteria.predicate.CompoundPredicate.render(CompoundPredicate.java:132) at org.hibernate.jpa.criteria.predicate.CompoundPredicate.render(CompoundPredicate.java:122) at org.hibernate.jpa.criteria.QueryStructure.render(QueryStructure.java:262) at org.hibernate.jpa.criteria.CriteriaQueryImpl.interpret(CriteriaQueryImpl.java:312) at org.hibernate.jpa.criteria.compile.CriteriaCompiler.compile(CriteriaCompiler.java:147) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:736) {code} The same code works fine on EclipseLink. Seems that the problem is in the MapKeyHelpers.MapKeySource constructor, which calls the super constructor from AbstractPathSource with a null pathSource argument: {code:java} super( criteriaBuilder, javaType, null ); {code} This way, the pathSource is initialized to null. Then, AbstractPathSource's getPathIdentifier() will always throw a NPE.

    Hibernate JIRA | 3 years ago | Peter Halicky
    java.lang.NullPointerException
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    Android: Saving Map State in Google map

    Stack Overflow | 11 months ago | Junie Negentien
    java.lang.RuntimeException: Unable to resume activity {com.ourThesis.junieNegentien2015/com.ourThesis.junieNegentien2015.MainActivity}: java.lang.NullPointerException

  1. Malcshour 1 times, last 6 months ago
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.jpa.criteria.path.AbstractPathImpl.getPathIdentifier()
  2. org.hibernate.jpa
    AbstractEntityManagerImpl.createQuery
    1. org.hibernate.jpa.criteria.path.AbstractPathImpl.getPathIdentifier(AbstractPathImpl.java:92)
    2. org.hibernate.jpa.criteria.path.AbstractPathImpl.render(AbstractPathImpl.java:252)
    3. org.hibernate.jpa.criteria.predicate.ComparisonPredicate.render(ComparisonPredicate.java:187)
    4. org.hibernate.jpa.criteria.predicate.AbstractSimplePredicate.render(AbstractSimplePredicate.java:65)
    5. org.hibernate.jpa.criteria.predicate.CompoundPredicate.render(CompoundPredicate.java:186)
    6. org.hibernate.jpa.criteria.predicate.CompoundPredicate.render(CompoundPredicate.java:132)
    7. org.hibernate.jpa.criteria.predicate.CompoundPredicate.render(CompoundPredicate.java:122)
    8. org.hibernate.jpa.criteria.QueryStructure.render(QueryStructure.java:262)
    9. org.hibernate.jpa.criteria.CriteriaQueryImpl.interpret(CriteriaQueryImpl.java:312)
    10. org.hibernate.jpa.criteria.compile.CriteriaCompiler.compile(CriteriaCompiler.java:147)
    11. org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:736)
    11 frames