From 5b845c0ca76914c34f97843d29da21c7ddede826 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Mon, 18 Jun 2007 23:14:26 +0000 Subject: [PATCH] --- .../samskivert/jdbc/depot/clause/Join.java | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/java/com/samskivert/jdbc/depot/clause/Join.java b/src/java/com/samskivert/jdbc/depot/clause/Join.java index 167d2ae..06e92fa 100644 --- a/src/java/com/samskivert/jdbc/depot/clause/Join.java +++ b/src/java/com/samskivert/jdbc/depot/clause/Join.java @@ -33,10 +33,13 @@ import com.samskivert.jdbc.depot.operator.Conditionals.*; import com.samskivert.jdbc.depot.operator.SQLOperator; /** - * Represents a JOIN -- currently just an INNER one. + * Represents a JOIN. */ public class Join extends QueryClause { + /** Indicates the join type to be used. The default is INNER. */ + public static enum Type { INNER, LEFT_OUTER, RIGHT_OUTER }; + public Join (Class pClass, String pCol, Class joinClass, String jCol) throws PersistenceException @@ -67,10 +70,29 @@ public class Join extends QueryClause return set; } + /** + * Configures the type of join to be performed. + */ + public Join setType (Type type) + { + _type = type; + return this; + } + // from QueryClause public void appendClause (ConstructedQuery query, StringBuilder builder) { - builder.append(" inner join " ); + switch (_type) { + case INNER: + builder.append(" inner join " ); + break; + case LEFT_OUTER: + builder.append(" left outer join " ); + break; + case RIGHT_OUTER: + builder.append(" right outer join " ); + break; + } builder.append(query.getTableName(_joinClass)).append(" as "); builder.append(query.getTableAbbreviation(_joinClass)).append(" on "); _joinCondition.appendExpression(query, builder); @@ -83,6 +105,9 @@ public class Join extends QueryClause return _joinCondition.bindArguments(pstmt, argIdx); } + /** Indicates the type of join to be performed. */ + protected Type _type = Type.INNER; + /** The class of the table we're to join against. */ protected Class _joinClass;