diff options
Diffstat (limited to 'src/main/java/com/iciql')
-rw-r--r-- | src/main/java/com/iciql/Query.java | 6 | ||||
-rw-r--r-- | src/main/java/com/iciql/TableDefinition.java | 11 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/main/java/com/iciql/Query.java b/src/main/java/com/iciql/Query.java index d1528e8..e9404ec 100644 --- a/src/main/java/com/iciql/Query.java +++ b/src/main/java/com/iciql/Query.java @@ -291,7 +291,11 @@ public class Query<T> { List<T> result = Utils.newArrayList(); TableDefinition<T> def = from.getAliasDefinition(); SQLStatement stat = getSelectStatement(distinct); - def.appendSelectList(stat); + if (isJoin()) { + def.appendSelectList(stat, from.getAs()); + } else { + def.appendSelectList(stat); + } appendFromWhere(stat); ResultSet rs = stat.executeQuery(); try { diff --git a/src/main/java/com/iciql/TableDefinition.java b/src/main/java/com/iciql/TableDefinition.java index fe273c0..05cdbf6 100644 --- a/src/main/java/com/iciql/TableDefinition.java +++ b/src/main/java/com/iciql/TableDefinition.java @@ -1150,6 +1150,17 @@ public class TableDefinition<T> { } } + void appendSelectList(SQLStatement stat, String as) { + for (int i = 0; i < fields.size(); i++) { + if (i > 0) { + stat.appendSQL(", "); + } + stat.appendSQL(as + "."); + FieldDefinition def = fields.get(i); + stat.appendColumn(def.columnName); + } + } + <Y, X> void appendSelectList(SQLStatement stat, Query<Y> query, X x) { // select t0.col1, t0.col2, t0.col3... // select table1.col1, table1.col2, table1.col3... |