I'm trying to get a field name from one table that has a join using hibernate. Does someone know how to get it? I'm using spring boot with EntityManager. The query is:
"SELECT COUNT(post_id), t.name" +
" FROM TagsPosts tp" +
" JOIN Tags t" +
" WHERE t.id = tp.tags_id" +
" GROUP BY tags_id" +
" ORDER BY 1 DESC"
I tried this code
Query query = entityManager.createQuery(
"SELECT COUNT(post_id), t.name" +
" FROM TagsPosts tp" +
" JOIN Tags t" +
" WHERE t.id = tp.tags_id" +
" GROUP BY tags_id" +
" ORDER BY 1 DESC");
query.setMaxResults(10);
for (Object queryResult: query.getResultList()) {
...
But it is not working.