import org.nutz.dao.sql.Sql;
import org.nutz.dao.sql.SqlCallback;
import java.lang.reflect.ParameterizedType;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedHashMap;
import java.util.Map;
public class ValueMapCallback<K, V> implements SqlCallback {
@Override
public Map<K, V> invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
Map<K, V> result = new LinkedHashMap<K, V>();
Class<V> clazz = (Class<V>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[1];
while (rs.next()) {
K k = (K) rs.getObject(1);
V v;
if (clazz == Integer.class) {
v = (V) rs.getObject(2);
} else {
v = (V) rs.getObject(2);
}
result.put(k, v);
}
return result;
}
}
SELECT first_judge_id user_id,COUNT(ui.pk_user_id) audit_count FROM user_info ui WHERE user_first_credit_time>'2018-08-26 00:00:00' and first_judge_id>0 group by ui.first_judge_id ORDER BY audit_count asc
sql.setCallback(new ValueMapCallback<Integer, Integer>());
最得到的结果value居然是Long类型的?求教问题出哪里了