I set up a select to make a query and sort by dt_payment, and this is giving an error complaining about incorrect syntax, I already looked in other forums and can’t find a solution, I ask for help for this case follow the code:
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;