if (arg instanceof Map) {
msp.addValues((Map)arg);
continue;
}
BeanPropertySqlParameterSource sps = new BeanPropertySqlParameterSource(arg);
List<Field> fields = new ArrayList<Field>();
for (Class<?> c = arg.getClass(); c != null; c = c.getSuperclass()) {
if (c.equals(Object.class))
continue;
fields.addAll(Arrays.asList(c.getDeclaredFields()));
}
for (Field f : fields) {
try {
String fn = f.getName();
if (msp.hasValue(fn))
sqlLogger.warn(String
.format("Field with name=%s has "
+ "been already mapped by another arg bean. Overriding!",
fn));
if (Enum.class.isAssignableFrom(f.getType())) {
sps.registerSqlType(f.getName(), Types.VARCHAR);
}
msp.addValue(fn, sps.getValue(fn), sps.getSqlType(fn),
sps.getTypeName(fn));
logger.debug(String.format("prepared sql arg: name=%s, value=%s, type=%s",
fn, sps.getValue(fn), sps.getTypeName(fn)));
} catch (Exception e) {
Throwables.propagate(e);
}
}
}