gistfile1.txt /**查询语句生成器*/public static String getSelectSql(List columns,Class c){StringBuffer sb=new StringBuffer();StringBuffer whereSB=new StringBuffer();sb.append("select ");for (String string : columns) {sb.append(string.
/**查询语句生成器*/ public static String getSelectSql(Listcolumns,Class c){ StringBuffer sb=new StringBuffer(); StringBuffer whereSB=new StringBuffer(); sb.append("select "); for (String string : columns) { sb.append(string.replace('_', '.')); sb.append(" as \""+string+"\","); } sb.delete(sb.length()-1, sb.length()); sb.append(" from "); //生成关联表名和where条件 createTablesAndWhere(c,sb,whereSB); //去掉尾巴 sb.delete(sb.length()-1, sb.length()); sb.append(" where "+c.getSimpleName()+".id=?"); whereSB.delete(whereSB.length()-3, whereSB.length()); sb.append(whereSB); //装载数据 return sb.toString(); }