db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r535615 - in /db/torque/runtime/trunk/src/java/org/apache/torque/util: BasePeer.java Criteria.java JoinBuilder.java
Date Sun, 06 May 2007 14:11:06 GMT
Author: tv
Date: Sun May  6 07:11:05 2007
New Revision: 535615

URL: http://svn.apache.org/viewvc?view=rev&rev=535615
Log:
Make joins and aliases to behave like all other lists and maps in
Criteria. This makes a couple of null-checks obsolete.

Modified:
    db/torque/runtime/trunk/src/java/org/apache/torque/util/BasePeer.java
    db/torque/runtime/trunk/src/java/org/apache/torque/util/Criteria.java
    db/torque/runtime/trunk/src/java/org/apache/torque/util/JoinBuilder.java

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/util/BasePeer.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/util/BasePeer.java?view=diff&rev=535615&r1=535614&r2=535615
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/util/BasePeer.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/util/BasePeer.java Sun May  6 07:11:05
2007
@@ -1573,7 +1573,7 @@
                 {
                     // try aliases
                     Map aliases = criteria.getAliases();
-                    if (aliases != null && aliases.get(tableName) != null)
+                    if (aliases.get(tableName) != null)
                     {
                         tableName = (String) aliases.get(tableName);
                         tableMap = databaseMap.getTable(tableName);

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/util/Criteria.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/util/Criteria.java?view=diff&rev=535615&r1=535614&r2=535615
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/util/Criteria.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/util/Criteria.java Sun May  6 07:11:05
2007
@@ -160,7 +160,7 @@
     private UniqueList groupByColumns = new UniqueList();
     private Criterion having = null;
     private OrderedMap asColumns = ListOrderedMap.decorate(new HashMap());
-    private transient List joins = null;
+    private transient List joins = new ArrayList(3);
 
     /** The name of the database. */
     private String dbName;
@@ -177,7 +177,7 @@
     /** To start the results at a row other than the first one. */
     private int offset = 0;
 
-    private HashMap aliases = null;
+    private HashMap aliases = new HashMap(8);
 
     private boolean useTransaction = false;
 
@@ -244,11 +244,11 @@
         groupByColumns.clear();
         having = null;
         asColumns.clear();
-        joins = null;
+        joins.clear();
         dbName = originalDbName;
         offset = 0;
         limit = -1;
-        aliases = null;
+        aliases.clear();
         useTransaction = false;
     }
 
@@ -305,10 +305,6 @@
      */
     public void addAlias(String alias, String table)
     {
-        if (aliases == null)
-        {
-            aliases = new HashMap(8);
-        }
         aliases.put(alias, table);
     }
 
@@ -320,10 +316,6 @@
      */
     public String getTableForAlias(String alias)
     {
-        if (aliases == null)
-        {
-            return null;
-        }
         return (String) aliases.get(alias);
     }
 
@@ -1353,10 +1345,6 @@
      */
     public Criteria addJoin(String left, String right, SqlEnum operator)
     {
-        if (joins == null)
-        {
-            joins = new ArrayList(3);
-        }
         joins.add(new Join(left, right, operator));
 
         return this;
@@ -1365,8 +1353,8 @@
     /**
      * get the List of Joins.  This method is meant to
      * be called by BasePeer.
-     * @return a List which contains objects of type Join,
-     *         or null if the criteria dies not contains any joins
+     * @return a List which contains objects of type Join.
+     *         If the criteria does not contains any joins, the list is empty
      */
     public List getJoins()
     {
@@ -1841,9 +1829,9 @@
                     && selectModifiers.equals(criteria.getSelectModifiers())
                     && selectColumns.equals(criteria.getSelectColumns())
                     && orderByColumns.equals(criteria.getOrderByColumns())
-                    && ObjectUtils.equals(aliases, criteria.getAliases())
+                    && aliases.equals(criteria.getAliases())
                     && asColumns.equals(criteria.getAsColumns())
-                    && ObjectUtils.equals(joins, criteria.getJoins())
+                    && joins.equals(criteria.getJoins())
                 )
             {
                 isEquiv = true;
@@ -1888,9 +1876,9 @@
         result = 37 * result + selectModifiers.hashCode();
         result = 37 * result + selectColumns.hashCode();
         result = 37 * result + orderByColumns.hashCode();
-        result = 37 * result + (aliases == null ? 0 : aliases.hashCode());
+        result = 37 * result + aliases.hashCode();
         result = 37 * result + asColumns.hashCode();
-        result = 37 * result + (joins == null ? 0 : joins.hashCode());
+        result = 37 * result + joins.hashCode();
         result = 37 * result + super.hashCode();
         return result;
     }
@@ -3061,7 +3049,7 @@
 
         // Joins need to be serialized manually.
         ArrayList serializableJoins = null;
-        if (joins != null && joins.size() > 0)
+        if (!joins.isEmpty())
         {
             serializableJoins = new ArrayList(joins.size());
 
@@ -3106,6 +3094,8 @@
         }
 
         // Joins need to be deserialized manually.
+        this.joins = new ArrayList(3);
+        
         ArrayList joins = (ArrayList) s.readObject();
         if (joins != null)
         {

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/util/JoinBuilder.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/util/JoinBuilder.java?view=diff&rev=535615&r1=535614&r2=535615
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/util/JoinBuilder.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/util/JoinBuilder.java Sun May  6 07:11:05
2007
@@ -61,7 +61,7 @@
     {
         List criteriaJoins = criteria.getJoins();
 
-        if (criteriaJoins == null)
+        if (criteriaJoins.isEmpty())
         {
             return;
         }



---------------------------------------------------------------------
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