JDBC 映射方式

1.映射成MAP方式

        List list = this.createSqlQuery(sql, parameter).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).list();
        if(list!=null&&list.size()>0){
            Map map = (Map)list.get(0);
            String rule_flag = map.get("RULE_FLAG")==null?"":map.get("RULE_FLAG").toString();
            if(StringUtils.isBlank(rule_flag)){
                rule_flag="0";
            }
            return rule_flag;
        }

2.映射成实体Bean

List<Student> list = this.createSqlQueryAddEntity(sql, parameter, Student.class).list();

3.数组取值

List<Object []> list = this.findBySql(sql,parameter);
        for(int i=0;i<list.size();i++){
            Object[] o = list.get(i);
            System.out.println("xxx="+o[1]);
            System.out.println("id="+o[0]);
        }

你可能感兴趣的:(java,sql,jdbc)