title: JPA alternative of Hibernate Projections.property
body: <p>Folks!</p>
  
  <p>Trying to limit amount of columns fetched from DB and found this: <a href="https://stackoverflow.com/questions/11626761/hibernate-criteria-query-to-get-specific-columns">Hibernate Criteria Query to get specific columns</a></p>
  
  <pre><code>Criteria cr = session.createCriteria(User.class)
      .setProjection(Projections.projectionList()
        .add(Projections.property("id"), "id")
        .add(Projections.property("Name"), "Name"))
      .setResultTransformer(Transformers.aliasToBean(User.class));
  
    List&lt;User&gt; list = cr.list();
  </code></pre>
  
  <p>This works awesome when you use Hibernate, but I am trying to do the same with <strong>JPA</strong> (JPA provider is <strong>Hibernate</strong> tho). <strong><em>Is it possible to do it with JPA?</em></strong> I mean limit columns with CriteriaBuilder and map to specific Object?</p>
  
  <p>Also, I saw this:
  <a href="https://docs.jboss.org/hibernate/orm/5.0/userguide/html_single/chapters/query/criteria/Criteria.html" rel="nofollow noreferrer">https://docs.jboss.org/hibernate/orm/5.0/userguide/html_single/chapters/query/criteria/Criteria.html</a></p>
  
  <pre><code>Hibernate offers an older, legacy org.hibernate.Criteria API which should be considered deprecated. No feature development will target those APIs. Eventually, Hibernate-specific criteria features will be ported as extensions to the JPA javax.persistence.criteria.CriteriaQuery. For details on the org.hibernate.Criteria API, see Legacy Hibernate Criteria Queries.
  </code></pre>
  
  <p>So seems like it is possible to do this via hibernate extensions for JPA?</p>