List list = dao.list(sql);
Map<String,String> map = dao.map(sql);
4 回复
估计你是想问自定义sql的各种回调
Sql sql = Sqls.create(".........");
sql.setCallback(Sqls.callback.maps());
Map map = dao.execute(sql).getList(Map.class);
@wendal Hashtable htable = new Hashtable();
sql.setCallback(new SqlCallback(htable) {
public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
String key = "";
String value = "";
while (rs.next()) {
ResultSetMetaData rsmd = rs.getMetaData();
if (rsmd.getColumnType(1) == 2005)
key = StringUtil.null2String(DBObject.getClobBody(rs, rsmd.getColumnName(1)));
else {
key = StringUtil.null2String(rs.getString(1));
}
if (rsmd.getColumnType(2) == 2005)
value = StringUtil.null2String(DBObject.getClobBody(rs, rsmd.getColumnName(2)));
else {
value = StringUtil.null2String(rs.getString(2));
}
this.val$htable.put(key, value);
}
return null;
}
});
dao.execute(new Sql[] { sql });
return htable;
这样的自动生成的类库,不用我去写呢?
添加回复
请先登陆