|
I'm using MapJoin like this:
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);
The em.createQuery(cq) call throws a NullPointerException:
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)
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:
super( criteriaBuilder, javaType, null );
This way, the pathSource is initialized to null. Then, AbstractPathSource's getPathIdentifier() will always throw a NPE.
|