conversion to a data type?

0

Good I am doing the manual mapping of the classes (tax), the problem is when I want to save an entity. '

public static <T> Object setEntity(T entity, Map<String, String> params) throws Exception {
        Class c = entity.getClass();
        Object o = c.newInstance();
        // Class<?>[] paramTypes2 = {String.class,
        // Integer.class,Double.class,Date.class};
        for (Map.Entry<String, String> entry : params.entrySet()) {

            java.lang.reflect.Field field = c.getDeclaredField(entry.getKey());
            //System.out.println("clave=" + entry.getKey() + ", valor=" + entry.getValue());
            Class<?>[] paramTypes = { field.getType() };
            java.lang.reflect.Method method = c.getMethod("set" + entry.getKey(), paramTypes);
            Class typoClass = Class.forName(paramTypes.toString());
            System.out.println("la clases"+typoClass.getName().toString());
            // method.invoke(o, entry.getValue());//aca esta el error parece //que no esta recibiendo el parametro deseado para hacer el "set"
        }

        return o;
    }

'

How could the required data type change?

    
asked by 04.01.2018 в 22:04
source

0 answers