Caros amigos, estou trabalhando numa manutenção de site que eles querem a ordenação das datas de pagamento, porem esta dando o seguinte erro: Incorrect syntax near the keyword ‘order’. o metodo que montei ficou assim:
public List findListHolerith(String cpf) throws ServiceException{
List<Holerith> listaHolerith = null;
Session hSession = HibernateFactory.factory().getSession();
try{
Criteria hCriteria = hSession.createCriteria(Holerith.class);
hCriteria.add(Restrictions.eq(Holerith.PROP_cpf ,cpf));
hCriteria.add(Restrictions.sqlRestriction("convert(Date,Dtpagamento,103"));
hCriteria.addOrder(Order.desc(Holerith.PROP_dtPagamento));
listaHolerith = hCriteria.list();
} catch(HibernateException e){
log.error(e.getMessage());
throw new ServiceException(e);
} catch(Exception e) {
log.error(e.getMessage(), e);
throw new ServiceException(e);
}
return listaHolerith;
gostaria da ajuda para entender o que fiz errado. o campo dtpagamento no banco esta string e não pode mudar por isso acrescentei o convert.