I fetch an object using reflection as following. Here the field I fetched is mapped by hibernate Lazy loading.
final Field field = clazz.getDeclaredField(fieldName);
field.setAccessible(true);
Object obj = field.get(instance);
Then I use the resulting object as follows
obj.getClass().getDeclaredFields()
But this does not return me all the fields which is defined in the Object. This Object can be any of the entity in my JPA entities list. I believe there is a problem with using Object instead of casted object.
How can I do this, and get all the fields of this new found object.