Hello,
I've got a entity named "pj" and I want to extract only the year of one field and get all the years on a list. How to do that using detachedcriteria? I'm using postgre. See the sql:
Code:
select extract(year from pj.dt_criacao) as year
from tb_pj pj
group by extract(year from pj.dt_criacao)
order by year desc
I was starting using this...
Code:
DetachedCriteria criteria = DetachedCriteria.forClass(Pj.class, "pj");
criteria.setProjection(Projections.groupProperty("extract(year from dt_criacao)")); --> from this point I don't know how to do...
List<Integer> lista = getDao().getEntityManager().findByCriteria(criteria);
Thanks a lot