0

In my spring appication, I have the following method in amy generic service class (the try/catch blocks were omitted to keep it simple):

@Transactional
public Map<String, List<?>> getListaValores() {
    System.out.println(":"+this.getName());
    Map<String, List<?>> map = new HashMap<String, List<?>>();
    Entidade ent = null;
    List<String> lista = null;

    ent = (Entidade) this.entityClass.newInstance();
    lista = ent.getListaArgumentos();

    for(int i=0; i<lista.size(); i++)
    {
        System.out.println("::"+lista.get(i));
        Class<?> clazz;
        Dao<?> obj;

        String class_name = "com.spring.loja.model."+lista.get(i).toLowerCase()+".persistence."+lista.get(i)+"Home";
        clazz = Class.forName(class_name);
        obj = (Dao<?>) clazz.newInstance();

        if(clazz != null) {
            System.out.println("clazz not null");
            List<?> temp = obj.findAll();
            map.put(lista.get(i), temp);
        } else {
            System.out.println("clazz is null");
            map.put(lista.get(i), null);
        }
    }

    return map;
}

All it's ok until the execution reaches this line:

List<?> temp = obj.findAll();

where temp is receiving null, despite the fact the method findAll in the Dao class being executed, with the correct entity class.

Anyone can see what's wrong here?

Kleber Mota
  • 8,521
  • 31
  • 94
  • 188

0 Answers0