Get array values returned from another class

3

I need to pass the value of the variable sgEstado to the other class but I can not, the value is in return when debug , but I can not make the value quit in the other class. p>

 ArrayList estados;
            try {
                Session session = InitSessionFactory.getInstance().getCurrentSession();
                estados = (ArrayList) session.createCriteria(FilialComplementoTO.class).addOrder(Order.asc("sgEstado")).list();

            } catch (Exception e) {
                Logger.getLogger(this.getClass().getName()).error(e.getMessage());
                throw new IntegrationException(e);
            }
            return estados;
        }

Second code, if the value of the sgEstado exit in the "passed" below is fine, Thankful.

try {
            ctx.get(FilialComplementoTO.FILIAL_COMPLEMENTO_KEY);
            //FilialComplementoTO filialComplementoTO = (FilialComplementoTO) ctx.get(FilialComplementoTO.FILIAL_COMPLEMENTO_KEY);
            LocalizarLojasCompositeEntity localizarLojasCompositeEntity = new LocalizarLojasCompositeEntity();
            localizarLojasCompositeEntity.findEstadosBySgEstado();
            System.out.println(localizarLojasCompositeEntity.findEstadosBySgEstado());
            System.out.println("passou");
}
    
asked by anonymous 16.10.2014 / 14:17

1 answer

2

It seems to me that what you need to do is just scan the array returned by the method that gives the list of states:

try {
    ctx.get(FilialComplementoTO.FILIAL_COMPLEMENTO_KEY);
    //FilialComplementoTO filialComplementoTO = (FilialComplementoTO) ctx.get(FilialComplementoTO.FILIAL_COMPLEMENTO_KEY);
    LocalizarLojasCompositeEntity localizarLojasCompositeEntity = new LocalizarLojasCompositeEntity();
    estados = localizarLojasCompositeEntity.findEstadosBySgEstado();
    for(string estado : estados) {
        System.out.println(estado);
    }
    System.out.println("passou");
}

I placed it on GitHub for future reference.

I've kicked in that% w /% of% w /% exist strings . If not, you would need to change the type in ArrayList and if the type is another data structure, pick up the specific element you want to print.

    
16.10.2014 / 14:57