In JPQL, I can retrieve entities by :
query = entityManager.createQuery(\"select c from Category c\");
List categories = query.getResultList(
In HQL you can use list() function to get a list of Object[] array that contains result rows:
Query query = session.createQuery("select c.id,c.name from Category c");
List
in returned array 1-st element will be id, second - name.
for (Object[] row: rows) {
System.out.println(" ------------------- ");
System.out.println("id: " + row[0]);
System.out.println("name: " + row[1]);
}
If you want to use hibernate's Criteria API, you should use Projections.
With JPA it will work the same way:
List