lundi 7 mars 2016

How to reflect complex Field java lang

here's my code :

for(Agent agent : datasource) {
    boolean match = true;

    if (filters != null) {
        for (Iterator<String> it = filters.keySet().iterator(); it.hasNext();) {
            try {
                System.out.println("********* Filter Loop **********");
                String filterProperty = it.next();
                Object filterValue = filters.get(filterProperty);
                java.lang.reflect.Field flied=agent.getClass().getDeclaredField(filterProperty);
                flied.setAccessible(true);
                String fieldValue = String.valueOf(flied.get(agent));
                System.out.println(fieldValue +"tt"+filterValue.toString());
                if(filterValue == null || fieldValue.contains(filterValue.toString())) {
                    System.out.println("********* Filter Existe ***********");
                    match = true;
                }
                else {
                    match = false;
                    break;
                }
            } catch(Exception e) {
                System.out.println(e.toString());
                match = false;
            }
        }

and I have this exception :

java.lang.NoSuchFieldException: agentLieuNaissance.sousprefectureNom

agentLieuNaissance it refrences another entity





Aucun commentaire:

Enregistrer un commentaire