0
I need to make a query in the database and return only the values based on the variable, my code returns the list with all the data of the city field, I want to return only the cities based on the state that the user selected before. The return of the status (the variable that has to be inserted in hlq) would be 'sgEstad'
public List<FilialComplementoTO> findCidadesByDsCidade() throws IntegrationException {
List cidades;
List<FilialComplementoTO> listOk ;
try {
Session session = InitSessionFactory.getInstance().getCurrentSession();
StringBuffer hql = new StringBuffer();
hql.append(" select g.dsCidade from FilialComplementoTO g ");
hql.append(" group by g.dsCidade ");
Query objQuery = session.createQuery(hql.toString());
cidades = (List) objQuery.list();
listOk = new ArrayList<FilialComplementoTO>();
for(Object obj: cidades){
FilialComplementoTO comple = new FilialComplementoTO();
comple.setDsCidade(obj.toString());
listOk.add(comple);
}
System.out.println(cidades);
} catch (Exception e) {
Logger.getLogger(this.getClass().getName()).error(e.getMessage());
throw new IntegrationException(e);
}
return listOk;
}
jdbc itself uses the index starting with 1. +1 in response.
– DiogoSantana