Mejoré un poco la cosa:
Código Java:
Ver original if(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 && conditions != null){
Consulta += " " + this.createConditions(tab,where, conditions, parts);
}
}
return Consulta;
}
if(tables != null && style != null){
for(int i = 0; i < tables.length; i++){
if(!tables[i].equals(this.getTable())){
String ps
= "" + tables
[i
].
charAt(0); String pp
= "" + tables
[i
-1 ].
charAt(0); if(ps.equals(pp)){
ps += tables[i].charAt(1);
}
join += style[i-1] + " join " + tables[i] + " " + ps + " on" + this.createCombos(tables[i],tables[i -1]);
if(!tables[tables.length -1].equals(tables[i])){
join += " ";
}
}
}
}
return join;
}
String fk
= "" + emisor.
charAt(0); String pk
= "" + receptor.
charAt(0); if(fk.equals(pk)){
fk += receptor.charAt(1);
}
LinkedList<String> keys = this.objbd.getPrimaryKeys(emisor);
LinkedList<String> fays = this.objbd.getForeignKeys(receptor);
if(k.equals(f)){
combo += pk +"."+k +" = "+fk +"."+f;
break;
}
}
}
return combo;
}
tab[0] = this.getTable();
for(int i = 0; i < tables.length; i++){
tab[i+1] = tables[i];
}
return tab;
}
if(tables == null){
columns += c;
} else {
for(int i = 0; i < tables.length; i++){
String ps
= "" + tables
[i
].
charAt(0); if(tables.length > 1 && i > 0){
String pp
= "" + tables
[i
-1].
charAt(0); if(ps.equals(pp)){
ps += tables[i].charAt(1);
}
}
LinkedList<String>temp = this.objbd.getColumns(tables[i]);
if(c1.equals(c)){
columns += ps + "." + c;
}
}
}
}
if(!cols[cols.length -1].equals(c)){
columns += ",";
} else {
columns += " ";
}
}
return columns;
}
for(int i = 0 ; i < where.length; i++){
if(tables != null){
for(int j = 0; j < tables.length; j++){
String ps
= "" + tables
[j
].
charAt(0); if(tables.length > 1 && j > 0){
String pp
= "" + tables
[j
-1].
charAt(0); if(ps.equals(pp)){
ps += tables[j].charAt(1);
}
}
LinkedList<String>temp = this.objbd.getColumns(tables[j]);
if(c1.equals(where[i])){
where[i] = ps + "." + where[i];
}
}
}
}
}
for(int i = 0 ; i < where.length; i++){
if(conditions[i].equals("between") || conditions[i].equals("not between")){
condition += where[i] + " " + conditions[i] + " ? and ?";
}else if(conditions[i].equals("not null") || conditions[i].equals("null")){
condition += where[i] + " " + conditions[i];
} else {
condition += where[i] + " " + conditions[i] + " ?";
}
if(!where[where.length -1].equals(where[i])){
condition += " " + parts[i] + " ";
}
}
return condition;
}
pero no me pasa que para el group by y order by es parecido a lo anterior, ¿quería preguntar cómo mejorar los renombramientos? ya que hice que para que no me duplique que en tabla que le haga el join me concatene su segunda letra pero eso no funcionará por mucho, además me quedé pensando cómo hacer si tengo subconsultas?? ahí no sé que hacer.
espero sus respuestas y saludos.