db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1331333 - in /db/torque/torque4/trunk: torque-runtime/src/main/java/org/apache/torque/criteria/ torque-runtime/src/main/java/org/apache/torque/sql/ torque-runtime/src/main/java/org/apache/torque/util/ torque-test/src/test/java/org/apache/t...
Date Fri, 27 Apr 2012 10:13:11 GMT
Author: tfischer
Date: Fri Apr 27 10:13:10 2012
New Revision: 1331333

URL: http://svn.apache.org/viewvc?rev=1331333&view=rev
Log:
TORQUE-198
Move Join types from SqlEnum to an own enum JoinType

Added:
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/JoinType.java
  (with props)
Modified:
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/FromElement.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Join.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/SqlEnum.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/JoinBuilder.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Criteria.java
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/DeleteTest.java

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java?rev=1331333&r1=1331332&r2=1331333&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java
Fri Apr 27 10:13:10 2012
@@ -122,13 +122,13 @@ public class Criteria
     public static final SqlEnum CURRENT_TIME = SqlEnum.CURRENT_TIME;
 
     /** "LEFT JOIN" SQL statement */
-    public static final SqlEnum LEFT_JOIN = SqlEnum.LEFT_JOIN;
+    public static final JoinType LEFT_JOIN = JoinType.LEFT_JOIN;
 
     /** "RIGHT JOIN" SQL statement */
-    public static final SqlEnum RIGHT_JOIN = SqlEnum.RIGHT_JOIN;
+    public static final JoinType RIGHT_JOIN = JoinType.RIGHT_JOIN;
 
     /** "INNER JOIN" SQL statement */
-    public static final SqlEnum INNER_JOIN = SqlEnum.INNER_JOIN;
+    public static final JoinType INNER_JOIN = JoinType.INNER_JOIN;
 
     /** Whether to ignore the case in all String conditions in the criteria. */
     private boolean ignoreCase = false;
@@ -442,13 +442,13 @@ public class Criteria
      *
      * @param left A String with the left side of the join.
      * @param right A String with the right side of the join.
-     * @param operator The operator used for the join: must be one of null,
+     * @param joinType The operator used for the join: must be one of null,
      *        Criteria.LEFT_JOIN, Criteria.RIGHT_JOIN, Criteria.INNER_JOIN
      * @return A modified Criteria object.
      */
-    public Criteria addJoin(Column left, Column right, SqlEnum operator)
+    public Criteria addJoin(Column left, Column right, JoinType joinType)
     {
-        joins.add(new Join(left, right, operator));
+        joins.add(new Join(left, right, joinType));
 
         return this;
     }

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/FromElement.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/FromElement.java?rev=1331333&r1=1331332&r2=1331333&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/FromElement.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/FromElement.java
Fri Apr 27 10:13:10 2012
@@ -40,8 +40,8 @@ public class FromElement
      */
     private String fromExpression = null;
 
-    /** The type of the join, e.g. SqlEnum.LEFT_JOIN */
-    private SqlEnum joinType = null;
+    /** The type of the join, e.g. JoinType.LEFT_JOIN */
+    private JoinType joinType = null;
 
     /** The join condition, e.g. table_a.id = table_b.a_id */
     private String joinCondition = null;
@@ -69,7 +69,7 @@ public class FromElement
      *        e.g. <br />
      *        table_1<br />
      *        table_1 alias_for_table_1
-     * @param joinType the type of the join, e.g. SqlEnum.LEFT_JOIN,
+     * @param joinType the type of the join, e.g. JoinType.LEFT_JOIN,
      *        or null if no excplicit join is wanted
      * @param joinCondition the join condition,
      *        e.g. table_a.id = table_b.a_id,
@@ -79,7 +79,7 @@ public class FromElement
      */
     public FromElement(
             String fromExpression,
-            SqlEnum joinType,
+            JoinType joinType,
             String joinCondition)
     {
         this(fromExpression, joinType, joinCondition, null);
@@ -92,7 +92,7 @@ public class FromElement
      *        e.g. <br />
      *        table_1<br />
      *        table_1 alias_for_table_1
-     * @param joinType the type of the join, e.g. SqlEnum.LEFT_JOIN,
+     * @param joinType the type of the join, e.g. JoinType.LEFT_JOIN,
      *        or null if no explicit join is wanted
      * @param joinCondition the join condition,
      *        e.g. table_a.id = table_b.a_id,
@@ -104,7 +104,7 @@ public class FromElement
      */
     public FromElement(
             String fromExpression,
-            SqlEnum joinType,
+            JoinType joinType,
             String joinCondition,
             List<Object> preparedStatementReplacements)
     {
@@ -129,10 +129,10 @@ public class FromElement
     }
 
     /**
-     * @return the type of the join, e.g. SqlEnum.LEFT_JOIN,
+     * @return the type of the join, e.g. JoinType.LEFT_JOIN,
      *         or null if the join is not an explicit join
      */
-    public SqlEnum getJoinType()
+    public JoinType getJoinType()
     {
         return joinType;
     }

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Join.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Join.java?rev=1331333&r1=1331332&r2=1331333&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Join.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Join.java
Fri Apr 27 10:13:10 2012
@@ -38,14 +38,17 @@ public class Join implements Serializabl
     /** Version id for serializing. */
     private static final long serialVersionUID = 1L;
 
-    /** the left column of the join condition, not null. */
+    /** The left column of the join condition, not null. */
     private Column leftColumn = null;
 
-    /** the right column of the join condition, not null. */
+    /** The right column of the join condition, not null. */
     private Column rightColumn = null;
 
-    /** the type of the join (LEFT JOIN, ...), or null. */
-    private SqlEnum joinType = null;
+    /**
+     * The type of the join (LEFT JOIN, ...),
+     * or null for an implicit inner join.
+     */
+    private JoinType joinType = null;
 
     /**
      * Constructor
@@ -60,7 +63,7 @@ public class Join implements Serializabl
     public Join(
             final Column leftColumn,
             final Column rightColumn,
-            final SqlEnum joinType)
+            final JoinType joinType)
     {
         if (leftColumn == null)
         {
@@ -79,7 +82,7 @@ public class Join implements Serializabl
      * @return the type of the join, i.e. SqlEnum.LEFT_JOIN, ...,
      *         or null for adding the join condition to the where Clause
      */
-    public final SqlEnum getJoinType()
+    public final JoinType getJoinType()
     {
         return joinType;
     }

Added: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/JoinType.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/JoinType.java?rev=1331333&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/JoinType.java
(added)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/JoinType.java
Fri Apr 27 10:13:10 2012
@@ -0,0 +1,59 @@
+package org.apache.torque.criteria;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ *
+ * The possible explicit join types.
+ *
+ * @version $Id$
+ */
+public enum JoinType
+{
+    /** SQL Expression " LEFT JOIN ". */
+    LEFT_JOIN(" LEFT JOIN "),
+    /** SQL Expression " RIGHT JOIN ". */
+    RIGHT_JOIN(" RIGHT JOIN "),
+    /** SQL Expression " INNER JOIN ". */
+    INNER_JOIN(" INNER JOIN ");
+
+    /** The SQL expression for the join type. */
+    private String sql;
+
+    /**
+     * Constructor.
+     *
+     * @param sql The SQL expression for the join type.
+     */
+    private JoinType(String sql)
+    {
+        this.sql = sql;
+    }
+
+    /**
+     * Returns the SQL expression for the join type.
+     *
+     * @return the SQL expression, not null.
+     */
+    public String toString()
+    {
+        return sql;
+    }
+
+}

Propchange: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/JoinType.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/SqlEnum.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/SqlEnum.java?rev=1331333&r1=1331332&r2=1331333&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/SqlEnum.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/SqlEnum.java
Fri Apr 27 10:13:10 2012
@@ -118,15 +118,6 @@ public final class SqlEnum implements ja
     /** SQL Expression "CURRENT_TIME". */
     public static final SqlEnum CURRENT_TIME =
         new SqlEnum("CURRENT_TIME");
-    /** SQL Expression " LEFT JOIN ". */
-    public static final SqlEnum LEFT_JOIN =
-        new SqlEnum(" LEFT JOIN ");
-    /** SQL Expression " RIGHT JOIN ". */
-    public static final SqlEnum RIGHT_JOIN =
-        new SqlEnum(" RIGHT JOIN ");
-    /** SQL Expression " INNER JOIN ". */
-    public static final SqlEnum INNER_JOIN =
-        new SqlEnum(" INNER JOIN ");
     /** SQL Expression " ON ". */
     public static final SqlEnum ON =
         new SqlEnum(" ON ");

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/JoinBuilder.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/JoinBuilder.java?rev=1331333&r1=1331332&r2=1331333&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/JoinBuilder.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/JoinBuilder.java
Fri Apr 27 10:13:10 2012
@@ -27,7 +27,7 @@ import org.apache.torque.TorqueException
 import org.apache.torque.criteria.CriteriaInterface;
 import org.apache.torque.criteria.FromElement;
 import org.apache.torque.criteria.Join;
-import org.apache.torque.criteria.SqlEnum;
+import org.apache.torque.criteria.JoinType;
 import org.apache.torque.util.UniqueList;
 
 /**
@@ -82,7 +82,7 @@ public final class JoinBuilder
 
             // Check the join type and add the join to the
             // appropriate places in the query
-            SqlEnum joinType  = join.getJoinType();
+            JoinType joinType  = join.getJoinType();
 
             if (joinType == null)
             {
@@ -188,15 +188,15 @@ public final class JoinBuilder
      *
      * @return the reversed join type.
      */
-    private static SqlEnum reverseJoinType(final SqlEnum joinType)
+    private static JoinType reverseJoinType(final JoinType joinType)
     {
-        if (SqlEnum.LEFT_JOIN.equals(joinType))
+        if (JoinType.LEFT_JOIN.equals(joinType))
         {
-            return SqlEnum.RIGHT_JOIN;
+            return JoinType.RIGHT_JOIN;
         }
-        else if (SqlEnum.RIGHT_JOIN.equals(joinType))
+        else if (JoinType.RIGHT_JOIN.equals(joinType))
         {
-            return SqlEnum.LEFT_JOIN;
+            return JoinType.LEFT_JOIN;
         }
         else
         {

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Criteria.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Criteria.java?rev=1331333&r1=1331332&r2=1331333&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Criteria.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Criteria.java
Fri Apr 27 10:13:10 2012
@@ -41,6 +41,7 @@ import org.apache.torque.Torque;
 import org.apache.torque.TorqueException;
 import org.apache.torque.criteria.CriteriaInterface;
 import org.apache.torque.criteria.Join;
+import org.apache.torque.criteria.JoinType;
 import org.apache.torque.criteria.SqlEnum;
 import org.apache.torque.om.ObjectKey;
 import org.apache.torque.sql.OrderBy;
@@ -135,13 +136,13 @@ public class Criteria implements Seriali
     public static final SqlEnum CURRENT_TIME = SqlEnum.CURRENT_TIME;
 
     /** &quot;LEFT JOIN&quot; SQL statement */
-    public static final SqlEnum LEFT_JOIN = SqlEnum.LEFT_JOIN;
+    public static final JoinType LEFT_JOIN = JoinType.LEFT_JOIN;
 
     /** &quot;RIGHT JOIN&quot; SQL statement */
-    public static final SqlEnum RIGHT_JOIN = SqlEnum.RIGHT_JOIN;
+    public static final JoinType RIGHT_JOIN = JoinType.RIGHT_JOIN;
 
     /** &quot;INNER JOIN&quot; SQL statement */
-    public static final SqlEnum INNER_JOIN = SqlEnum.INNER_JOIN;
+    public static final JoinType INNER_JOIN = JoinType.INNER_JOIN;
 
     /** Whether to ignore the case in all String conditions in the criteria. */
     private boolean ignoreCase = false;
@@ -1280,7 +1281,7 @@ public class Criteria implements Seriali
      *        Criteria.LEFT_JOIN, Criteria.RIGHT_JOIN, Criteria.INNER_JOIN
      * @return A modified Criteria object.
      */
-    public Criteria addJoin(Column left, Column right, SqlEnum operator)
+    public Criteria addJoin(Column left, Column right, JoinType operator)
     {
         joins.add(new Join(left, right, operator));
 
@@ -1325,7 +1326,7 @@ public class Criteria implements Seriali
      *        Criteria.LEFT_JOIN, Criteria.RIGHT_JOIN, Criteria.INNER_JOIN
      * @return A modified Criteria object.
      */
-    public Criteria addJoin(String left, String right, SqlEnum operator)
+    public Criteria addJoin(String left, String right, JoinType operator)
     {
         joins.add(new Join(
                 new ColumnImpl(left),

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/DeleteTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/DeleteTest.java?rev=1331333&r1=1331332&r2=1331333&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/DeleteTest.java
(original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/DeleteTest.java
Fri Apr 27 10:13:10 2012
@@ -30,7 +30,6 @@ import org.apache.torque.ForeignKeySchem
 import org.apache.torque.PkSchemaData;
 import org.apache.torque.TorqueException;
 import org.apache.torque.criteria.Criteria;
-import org.apache.torque.criteria.SqlEnum;
 import org.apache.torque.om.NumberKey;
 import org.apache.torque.om.ObjectKey;
 import org.apache.torque.test.Nopk;
@@ -527,7 +526,7 @@ public class DeleteTest extends BaseData
         criteria.addJoin(
                 NullableOIntegerFkPeer.FK,
                 OIntegerPkPeer.ID,
-                SqlEnum.INNER_JOIN);
+                Criteria.INNER_JOIN);
         criteria.and(
                 OIntegerPkPeer.ID,
                 testData.getOIntegerPkList().get(0).getId());



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message