dimanche 15 avril 2018

java.lang.IllegalArgumentException: argument type mismatch.(Reflection) I used the right typeOfData

Why i have this exception? "java.lang.IllegalArgumentException: argument type mismatch". I used the right typeOfData.

public ArrayList createObjects(ResultSet myRs){

    ArrayList<T> list=new ArrayList<>();

    try{
        while(myRs.next()){
            T instance=type.newInstance();
            for(Field field:type.getDeclaredFields()) {
                Object value = myRs.getObject(field.getName());
                PropertyDescriptor propertyDescriptor = new PropertyDescriptor(field.getName(), type);
                Method method = propertyDescriptor.getWriteMethod();
                method.invoke(instance,value);
            }
            list.add(instance);
        }
    }catch(Exception e){
        System.out.println(e);
    }
    return list;





Aucun commentaire:

Enregistrer un commentaire