首页 > 代码库 > jfinal对象转Record原理【疑问】
jfinal对象转Record原理【疑问】
/*DbPro.class*/public transient Record findFirst(String sql, Object paras[]{List result = find(sql, paras);return result.size() <= 0 ? null : (Record)result.get(0);}public transient List find(String sql, Object paras[]){Connection conn = null;List list;try{conn = config.getConnection();list = find(config, conn, sql, paras);}catch(Exception e){throw new ActiveRecordException(e);}config.close(conn);return list;Exception exception;exception;config.close(conn);throw exception;}transient List find(Config config, Connection conn, String sql, Object paras[])throws SQLException{PreparedStatement pst = conn.prepareStatement(sql);config.dialect.fillStatement(pst, paras);ResultSet rs = pst.executeQuery();List result = RecordBuilder.build(config, rs); //返回List<Record>DbKit.closeQuietly(rs, pst);return result;}/*RecordBuilder.class*把一条记录对象封装Record对象*/public static final List build(Config config, ResultSet rs)throws SQLException{List result = new ArrayList();ResultSetMetaData rsmd = rs.getMetaData();int columnCount = rsmd.getColumnCount();String labelNames[] = new String[columnCount + 1];int types[] = new int[columnCount + 1];buildLabelNamesAndTypes(rsmd, labelNames, types);Record record;for(; rs.next(); result.add(record)){record = new Record();record.setColumnsMap(config.containerFactory.getColumnsMap());Map columns = record.getColumns();for(int i = 1; i <= columnCount; i++){Object value;if(types[i] < 2004)value = http://www.mamicode.com/rs.getObject(i);>
jfinal对象转Record原理【疑问】
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。