OPENJPA-1120 idEquals() broken in BigDecimalId and BigIntegerId. Patch contributed by Dieter Von Holten with additional updates from Albert Lee.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@799132 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Donald Woods 2009-07-29 23:53:18 +00:00
parent 8ca7664bd9
commit 16344b5b33
2 changed files with 20 additions and 17 deletions

View File

@ -52,23 +52,25 @@ public class BigDecimalId
} }
public String toString() { public String toString() {
if (key == null) if (key == null) {
return "NULL"; return "NULL";
}
return key.toString(); return key.toString();
} }
protected int idHash() { protected int idHash() {
if (key != null) if (key != null) {
return key.hashCode(); return key.hashCode();
}
return 0; return 0;
} }
protected boolean idEquals(OpenJPAId other) { protected boolean idEquals(OpenJPAId other) {
if(key == null) if ((key == null) ||
(!BigDecimalId.class.isAssignableFrom(other.getClass()))) {
return false; return false;
}
return key.equals(other); return key.equals(((BigDecimalId)other).key);
} }
} }

View File

@ -52,24 +52,25 @@ public class BigIntegerId
} }
public String toString() { public String toString() {
if (key == null) if (key == null) {
return "NULL"; return "NULL";
}
return key.toString(); return key.toString();
} }
protected int idHash() { protected int idHash() {
if (key != null) if (key != null) {
return key.hashCode(); return key.hashCode();
}
return 0; return 0;
} }
protected boolean idEquals(OpenJPAId other) { protected boolean idEquals(OpenJPAId other) {
if (key == null) if ((key == null) ||
(!BigIntegerId.class.isAssignableFrom(other.getClass()))) {
return false; return false;
return key.equals(other);
} }
return key.equals(((BigIntegerId)other).key);
}
} }