title: When to use the select clause in the JPA criteria API?
body: <ol>
  <li><p>Without using <code>CriteriaQuery#select()</code> :</p>
  
  <pre><code>public List&lt;Address&gt; getAddressOfManager(String designation, String name, String orderByColumn) {
  
      Boolean ascending = false;
      CriteriaBuilder cb = emanager.getCriteriaBuilder();
      CriteriaQuery&lt;Address&gt; cq = cb.createQuery(Address.class);
      Root&lt;Address&gt; root = cq.from(Address.class);
      //cq.select(root);  &lt;-------------
      Join&lt;Address, Employee&gt; employeeAddress = root.join(Address_.employee);
      Join&lt;Employee,Project&gt; employeeProject = employeeAddress.join(Employee_.project);
      cq.where(cb.or(cb.equal(employeeProject.get(Project_.name), name),cb.equal(employeeAddress.get(Employee_.designation), designation)));
      Order order = ascending ? cb.asc(root.get(orderByColumn))
              : cb.desc(root.get(orderByColumn));
      cq.orderBy(order);
      List&lt;Address&gt; result = emanager.createQuery(cq).getResultList();
      return result;
  }
  </code></pre></li>
  <li><p>With <code>CriteriaQuery#select()</code> :</p>
  
  <pre><code>public List&lt;Address&gt; getAddressOfManager(String designation, String name, String orderByColumn) {
  
      Boolean ascending = false;
      CriteriaBuilder cb = emanager.getCriteriaBuilder();
      CriteriaQuery&lt;Address&gt; cq = cb.createQuery(Address.class);
      Root&lt;Address&gt; root = cq.from(Address.class);
      cq.select(root); //&lt;----------------
      Join&lt;Address, Employee&gt; employeeAddress = root.join(Address_.employee);
      Join&lt;Employee,Project&gt; employeeProject = employeeAddress.join(Employee_.project);
      cq.where(cb.or(cb.equal(employeeProject.get(Project_.name), name),cb.equal(employeeAddress.get(Employee_.designation), designation)));
      Order order = ascending ? cb.asc(root.get(orderByColumn))
              : cb.desc(root.get(orderByColumn));
      cq.orderBy(order);
      List&lt;Address&gt; result = emanager.createQuery(cq).getResultList();
      return result;
  }
  </code></pre>
  
  <p>Now, I am confused as to when to use <code>select()</code> in JPA criteria query.</p></li>
  </ol>