title: Self join in criteria query
body: <p>so I have a table called 'User' having fields as</p>
  
  <ul>
  <li>userId</li>
  <li>userName</li>
  <li>supervisorId</li>
  </ul>
  
  <p>I want to fetch the userName of the supervisor of a particular user.</p>
  
  <pre><code>CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
  CriteriaQuery&lt;User&gt; criteriaQuery = criteriaBuilder.createQuery(User.class);
  Root&lt;User&gt; rootUser = criteriaQuery.from(User.class);
  List&lt;Predicate&gt; predList = new ArrayList&lt;Predicate&gt;();
  Join&lt;User, User&gt; selfJoin = rootUser.join("userId", JoinType.LEFT); //not sure about this line
  predList.add(criteriaBuilder.equal(selfJoin.&lt;String&gt;get("userId"), supervisorId)); //supervisorId is the id of the supervisor that I want to find
  TypedQuery&lt;User&gt; typedQuery = em.createQuery(criteriaQuery);
  List&lt;User&gt; resultList = typedQuery.getResultList();
  </code></pre>
  
  <p>Now I have many other conditions too beside this supervisorId. So I have to use the same criteria query. </p>
  
  <p>Thanks.</p>