title: jpa criteriabuilder join maps
body: <p>I have the following criteria builder query</p>
  
  <pre><code>    CriteriaBuilder cb = em.getCriteriaBuilder();
      CriteriaQuery&lt;Object&gt; critQuery = cb.createQuery();
  
      Root&lt;Role&gt; role = critQuery.from(Role.class);
  
      //create a join between role and permission
      MapJoin&lt;Role,String,Permission&gt; perm = role.joinMap("permissions");
      critQuery.multiselect(role.get("label"), perm.key(), perm.value());
  
      //this line throws NPE
      Query query = em.createQuery(critQuery);
  </code></pre>
  
  <p>The last line throws a null pointer exception. </p>
  
  <pre><code>java.lang.NullPointerException
  at org.hibernate.ejb.criteria.path.AbstractPathImpl.prepareAlias(AbstractPathImpl.java:246)
  at org.hibernate.ejb.criteria.path.AbstractPathImpl.render(AbstractPathImpl.java:253)
  at org.hibernate.ejb.criteria.path.AbstractPathImpl.renderProjection(AbstractPathImpl.java:261)
  </code></pre>