From 8490e3129f3be9d338ce95b5e2a0f08abe88575f Mon Sep 17 00:00:00 2001 From: mdb Date: Mon, 18 Jun 2007 23:14:26 +0000 Subject: [PATCH] git-svn-id: https://samskivert.googlecode.com/svn/trunk@2116 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../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 167d2ae6..06e92fae 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;