I have the following code to get the object which has the "Andamento" with the latest date (I have called date -> data).
DetachedCriteria criteriaAndamento = DetachedCriteria.forClass(Andamento.class);
criteriaAndamento.setProjection(Projections.projectionList()
.add(Projections.max("data").as(null))
.add(Projections.groupProperty("processo").as("id"))
);
criteriaAndamento.add(Restrictions.sqlRestriction("DATE_FORMAT(`data`, '%d/%m/%Y') like '" + filter.getFilterValue().toString() + "%'"));
criteria.add(Property.forName("id").in(criteriaAndamento));
But in this line of code: criteria.add(Property.forName("id").in(criteriaAndamento));
it gives the following error:
ERROR SqlExceptionHelper:129 - Operand should contain 1 column(s)...
So it expects the detachedCriteria to have only 1 column. But since I need both projections, how can I select only one column? Or maybe remove the other?
ps: I have removed the "max" projection and it works, so I need some way to select only the "processo" column from this detachedCriteria.