se vc tiver usando Criteria use Projection!!!
segue:
public List<Integer> exemplo(Integer valor) {
try {
Criteria criteria = getCurrentSession().createCriteria( Classe.class,"a");
criteria.setProjection(Projections
.property(("a.campo")));
criteria.add(Restrictions.eq("a.id",valor));
criteria.addOrder(Order.asc("a.campo"));
if(criteria.list().size()> 0){
List lista = (List<Integer>)criteria.list();
return lista;
}else{
throw new BusinessException("2.5-3",this.getClass());
}
}catch(Exception e){
throw new BusinessException("2.5-3",this.getClass());
}
}
Como eu faço pra retornar uma consulta que retorne um unico campo utlizando o JPA !?
Exemplo !?