if (arg instanceof MapSqlParameterSource) {
msp.addValues(((MapSqlParameterSource) arg).getValues());
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)) {
if (warnParamOverride) {
warnParamOverride = false;
logger.warn(String.format("Field with name=%s has "
+ "been already mapped by another arg bean. Overriding! Next time will warn if DEBUG is enabled.", fn));
} else {
if (logger.isDebugEnabled()) {
logger.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);
}
}
}