How to access multiple fields in a JPA request?

I have a JPA request of the form:

SELECT category, count(*) AS c FROM ...

I know that if the query just returns a single column, I can do something like:

List<Article> articles = query.getResultList();

However, how do I access the results when there are two or more columns, as in the above example?

+3
source share
1 answer

check out section 14.6 here: http://docs.jboss.org/hibernate/core/3.3/reference/en/html/queryhql.html#queryhql-select

it will return a list of objects [] if you select more than one column but do not get the actual object.

+2
source

Source: https://habr.com/ru/post/1796355/


All Articles