I am using reflections to map an ResultSet to a Field in bean.
field = clazz.getDeclaredField(str);
field.setAccessible(true);
Object resultSetObject = rs.getObject(str);
Class fieldType = field.getType();
field.set(clazzInst, fieldType.cast(resultSetObject));
The problem is resultSetObject is of type Integer and fieldType is of Long and I cannot cast Intger to Long and getting ClassCastException.