Hola a todos, les cuento que estuve trabajando en el select genérico y este es el resultado:
Código Java:
Ver originalif(cols == null){
Consulta += "* ";
} else {
Consulta += this.createColumns(cols, tables);
}
Consulta += "from " + this.getTable();
if(tables != null){
String[] tab
= this.
prepareTables(tables
); Consulta += " " + this.getTable().charAt(0);
Consulta += this.createJoin(style,tab);
}
if(where != null){
Consulta += " where ";
Consulta += w + " = ?";
if(!where[where.length -1].equals(w)){
Consulta += " and ";
}
}
}
return Consulta;
}
if(tables != null){
if(!t.equals(this.getTable())){
char ps = t.charAt(0);
join += style + " join " + t + " " + ps + " on" + this.createCombos(tables);
}
}
}
return join;
}
tab[0] = this.getTable();
for(int i = 0; i < tables.length; i++){
tab[i+1] = tables[i];
}
return tab;
}
for(int i = 0; i < tables.length -1; i++){
char fk = tables[i+1].charAt(0);
char pk = tables[i].charAt(0);
LinkedList<String> keys = this.objbd.getPrimaryKeys(tables[i+1]);
LinkedList<String> fays = this.objbd.getForeignKeys(tables[i]);
if(k.equals(f)){
combo += fk +"."+f +" = "+pk +"."+k;
}
}
}
}
return combo;
}
if(tables == null){
columns += c;
} else {
char s = t.charAt(0);
LinkedList<String>temp = this.objbd.getColumns(t);
if(c1.equals(c)){
columns += s + "." + c;
}
}
}
}
if(!cols[cols.length -1].equals(c)){
columns += ",";
} else {
columns += " ";
}
}
return columns;
}
lo que me faltaría es ver bien las condiciones, los order y group by, además debería probar con los renombramientos de sql xq de momento esta sólo obteniendo la primer letra cosa que no es muy buena idea, ya que si hay otra tabla con la misma letra inicial, la consulta queda fastidiada, no sé que me sugieren?