You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by dw...@apache.org on 2009/07/30 03:01:19 UTC

svn commit: r799142 - in /openjpa/branches/1.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/util: BigDecimalId.java BigIntegerId.java

Author: dwoods
Date: Thu Jul 30 01:01:18 2009
New Revision: 799142

URL: http://svn.apache.org/viewvc?rev=799142&view=rev
Log:
OPENJPA-1120 idEquals() broken in BigDecimalId and BigIntegerId.  Patch contributed by Dieter Von Holten with additional updates from Albert Lee.

Modified:
    openjpa/branches/1.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/util/BigDecimalId.java
    openjpa/branches/1.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/util/BigIntegerId.java

Modified: openjpa/branches/1.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/util/BigDecimalId.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/util/BigDecimalId.java?rev=799142&r1=799141&r2=799142&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/util/BigDecimalId.java (original)
+++ openjpa/branches/1.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/util/BigDecimalId.java Thu Jul 30 01:01:18 2009
@@ -14,7 +14,7 @@
  * "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.    
+ * under the License.
  */
 package org.apache.openjpa.util;
 
@@ -52,23 +52,25 @@
     }
 
     public String toString() {
-        if (key == null)
+        if (key == null) {
             return "NULL";
-
+        }
         return key.toString();
     }
 
     protected int idHash() {
-        if (key != null)
+        if (key != null) {
             return key.hashCode();
-
+        }
         return 0;
     }
 
     protected boolean idEquals(OpenJPAId other) {
-        if(key == null)
+        if ((key == null) ||
+            (!BigDecimalId.class.isAssignableFrom(other.getClass()))) {
             return false;
-
-        return key.equals(other);
+        }
+        return key.equals(((BigDecimalId)other).key);
     }
 }
+

Modified: openjpa/branches/1.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/util/BigIntegerId.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/util/BigIntegerId.java?rev=799142&r1=799141&r2=799142&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/util/BigIntegerId.java (original)
+++ openjpa/branches/1.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/util/BigIntegerId.java Thu Jul 30 01:01:18 2009
@@ -14,7 +14,7 @@
  * "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.    
+ * under the License.
  */
 package org.apache.openjpa.util;
 
@@ -52,24 +52,25 @@
     }
 
     public String toString() {
-        if (key == null)
+        if (key == null) {
             return "NULL";
-
+        }
         return key.toString();
     }
 
     protected int idHash() {
-        if (key != null)
+        if (key != null) {
             return key.hashCode();
-
+        }
         return 0;
     }
 
     protected boolean idEquals(OpenJPAId other) {
-        if (key == null)
+        if ((key == null) ||
+             (!BigIntegerId.class.isAssignableFrom(other.getClass()))) {
             return false;
-
-        return key.equals(other);
+        }
+        return key.equals(((BigIntegerId)other).key);
     }
-
 }
+