You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tf...@apache.org on 2007/05/06 12:05:07 UTC

svn commit: r535591 - in /db/torque: runtime/trunk/src/java/org/apache/torque/util/Criteria.java runtime/trunk/src/test/org/apache/torque/util/CriteriaTest.java site/trunk/xdocs/changes.xml

Author: tfischer
Date: Sun May  6 03:05:04 2007
New Revision: 535591

URL: http://svn.apache.org/viewvc?view=rev&rev=535591
Log:
Fixed Null Pointer Exceptions in Criteria.equals() and Criteria.hashCode() if joins are null. 
Thanks to Sean Gilligan. Fixes TORQUE-90.

Modified:
    db/torque/runtime/trunk/src/java/org/apache/torque/util/Criteria.java
    db/torque/runtime/trunk/src/test/org/apache/torque/util/CriteriaTest.java
    db/torque/site/trunk/xdocs/changes.xml

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=535591&r1=535590&r2=535591
==============================================================================
--- 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 03:05:04 2007
@@ -1843,7 +1843,7 @@
                     && orderByColumns.equals(criteria.getOrderByColumns())
                     && ObjectUtils.equals(aliases, criteria.getAliases())
                     && asColumns.equals(criteria.getAsColumns())
-                    && joins.equals(criteria.getJoins())
+                    && ObjectUtils.equals(joins, criteria.getJoins())
                 )
             {
                 isEquiv = true;
@@ -1890,7 +1890,7 @@
         result = 37 * result + orderByColumns.hashCode();
         result = 37 * result + (aliases == null ? 0 : aliases.hashCode());
         result = 37 * result + asColumns.hashCode();
-        result = 37 * result + joins.hashCode();
+        result = 37 * result + (joins == null ? 0 : joins.hashCode());
         result = 37 * result + super.hashCode();
         return result;
     }

Modified: db/torque/runtime/trunk/src/test/org/apache/torque/util/CriteriaTest.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/test/org/apache/torque/util/CriteriaTest.java?view=diff&rev=535591&r1=535590&r2=535591
==============================================================================
--- db/torque/runtime/trunk/src/test/org/apache/torque/util/CriteriaTest.java (original)
+++ db/torque/runtime/trunk/src/test/org/apache/torque/util/CriteriaTest.java Sun May  6 03:05:04 2007
@@ -633,6 +633,20 @@
     }
 
     /**
+     * Test that {@link Criteria#equals(Object)} works correctly for a simple
+     * Criteria object.
+     * @throws TorqueException
+     */
+    public void testEquals() throws TorqueException
+    {
+        c.addSelectColumn("Author.NAME");
+        c.addSelectColumn("Author.AUTHOR_ID");
+        c.add("Author.NAME", "foobar");
+        Criteria cClone = (Criteria) SerializationUtils.clone(c);
+        assertTrue(c.equals(cClone));
+    }
+
+    /**
      * Checks whether orderBy works.
      */
     public void testOrderBy() throws TorqueException

Modified: db/torque/site/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/db/torque/site/trunk/xdocs/changes.xml?view=diff&rev=535591&r1=535590&r2=535591
==============================================================================
--- db/torque/site/trunk/xdocs/changes.xml (original)
+++ db/torque/site/trunk/xdocs/changes.xml Sun May  6 03:05:04 2007
@@ -31,6 +31,10 @@
 
   <body>
   <release version="3.3-RC3" date="in SVN">
+    <action type="fix" dev="tfischer" issue="TORQUE-90" due-to="Sean Gilligan">
+      Fixed Null Pointer Exceptions in Criteria.equals() and
+      Criteria.hashCode() if joins are null. 
+    </action>
     <action type="fix" dev="tfischer">
       Changed the maven2 plugin's datadump goal to accept only a single schema
       xml. Multiple schema xmls produced illegal output. 



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


Re: svn commit: r535591 - in /db/torque: runtime/trunk/src/java/org/apache/torque/util/Criteria.java runtime/trunk/src/test/org/apache/torque/util/CriteriaTest.java site/trunk/xdocs/changes.xml

Posted by Thomas Fischer <fi...@seitenbau.net>.
Yes, if you initialize the joins list, it would never be null and the
TORQUE-90 changes would not be necessary.

   Thomas

Thomas Vandahl <tv...@apache.org> schrieb am 06.05.2007 15:26:50:

> Thomas Fischer wrote:
> > There is no particular reason why the joins are initialized as null and
> > not as empty list. If you want to change that, please go ahead.
>
> Ok, I'll do that. This would also mean to roll back the stuff to fix
> TORQUE-90, because joins would never be null, agreed? Looks somehow more
> regular...
>
> Bye, Thomas.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-dev-help@db.apache.org
>


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


Re: svn commit: r535591 - in /db/torque: runtime/trunk/src/java/org/apache/torque/util/Criteria.java runtime/trunk/src/test/org/apache/torque/util/CriteriaTest.java site/trunk/xdocs/changes.xml

Posted by Thomas Vandahl <tv...@apache.org>.
Thomas Fischer wrote:
> There is no particular reason why the joins are initialized as null and
> not as empty list. If you want to change that, please go ahead.

Ok, I'll do that. This would also mean to roll back the stuff to fix
TORQUE-90, because joins would never be null, agreed? Looks somehow more
regular...

Bye, Thomas.

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


Re: svn commit: r535591 - in /db/torque: runtime/trunk/src/java/org/apache/torque/util/Criteria.java runtime/trunk/src/test/org/apache/torque/util/CriteriaTest.java site/trunk/xdocs/changes.xml

Posted by Thomas Fischer <tf...@apache.org>.
The transient was added by Scott when he tried to serialize the Criteria. 
Somehow the default serialisation mechanism did not work for the 
Criteria.Join object; no idea why.
There is no particular reason why the joins are initialized as null and 
not as empty list. If you want to change that, please go ahead.

   Thomas

On Sun, 6 May 2007, Thomas Vandahl wrote:

> tfischer@apache.org wrote:
>>                      && asColumns.equals(criteria.getAsColumns())
>> -                    && joins.equals(criteria.getJoins())
>> +                    && ObjectUtils.equals(joins, criteria.getJoins())
>
> Actually, I had a look at that code and I asked myself why the list of
> joins is handled differently than all other lists in Criteria. Is there
> any particular reason why this list is not initialized as empty and
> declared as transient?
>
>
> Bye, Thomas.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-dev-help@db.apache.org
>
>

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


Re: svn commit: r535591 - in /db/torque: runtime/trunk/src/java/org/apache/torque/util/Criteria.java runtime/trunk/src/test/org/apache/torque/util/CriteriaTest.java site/trunk/xdocs/changes.xml

Posted by Thomas Vandahl <tv...@apache.org>.
tfischer@apache.org wrote:
>                      && asColumns.equals(criteria.getAsColumns())
> -                    && joins.equals(criteria.getJoins())
> +                    && ObjectUtils.equals(joins, criteria.getJoins())

Actually, I had a look at that code and I asked myself why the list of
joins is handled differently than all other lists in Criteria. Is there
any particular reason why this list is not initialized as empty and
declared as transient?


Bye, Thomas.

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