Permalink
Browse files

More simplification..

  • Loading branch information...
1 parent 2b00a9c commit 547416bbb6ba1b2dad5b12689650b2d438986543 @detinho committed Apr 10, 2012
Showing with 6 additions and 15 deletions.
  1. +6 −15 src/main/java/br/com/detinho/sqlbuilder/Select.java
@@ -35,10 +35,7 @@ public void column(String tableName, String columnName) {
}
public String toSql() {
- collectTablesFromColumns();
- collectTablesFromCriteria();
- collectTablesFromJoins();
- collectTablesFromOrderBy();
+ collectTables();
String sql = "SELECT ";
sql = generateColumnsSql(sql);
@@ -51,22 +48,16 @@ public String toSql() {
return sql;
}
- private void collectTablesFromJoins() {
+ private void collectTables() {
+ for (Selectable sel : columns)
+ sel.addTable(tables);
+
for (Join join : joins)
join.addTable(tables);
- }
- private void collectTablesFromColumns() {
- for (Selectable sel : columns)
- sel.addTable(tables);
- }
-
- private void collectTablesFromCriteria() {
if (criteria != null)
criteria.addTable(tables);
- }
-
- private void collectTablesFromOrderBy() {
+
for (OrderBy order : orders)
order.addTable(tables);
}

0 comments on commit 547416b

Please sign in to comment.