You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by th...@apache.org on 2003/12/19 18:51:04 UTC
cvs commit: db-ojb/src/java/org/apache/ojb/broker Identity.java
thma 2003/12/19 09:51:04
Modified: src/java/org/apache/ojb/broker Identity.java
Log:
fix to #OJB230, patched as proposed by Dave Clark.
should go into 1.0 and later
Revision Changes Path
1.29 +22 -3 db-ojb/src/java/org/apache/ojb/broker/Identity.java
Index: Identity.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/Identity.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- Identity.java 28 Nov 2003 14:39:59 -0000 1.28
+++ Identity.java 19 Dec 2003 17:51:04 -0000 1.29
@@ -65,6 +65,7 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
+import java.util.Arrays;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
@@ -335,7 +336,13 @@
{
result = (m_pkValues[i] == null) ? (otherPkValues[i] == null)
: m_pkValues[i].equals(otherPkValues[i]);
- }
+
+ // special treatment for byte[]
+ if (!result && m_pkValues[i] instanceof byte[] && otherPkValues[i] instanceof byte[])
+ {
+ result = Arrays.equals((byte[]) m_pkValues[i], (byte[]) otherPkValues[i]);
+ }
+ }
}
else
{
@@ -364,7 +371,19 @@
for (int i = 0; i < m_pkValues.length; i++)
{
- if (m_pkValues[i] != null) result ^= m_pkValues[i].hashCode();
+ // special treatment for computing byte[] hashcode
+ if (m_pkValues[i] != null && m_pkValues[i] instanceof byte[])
+ {
+ byte[] bytes = (byte[]) m_pkValues[i];
+ for (int j =0; j < bytes.length; j++)
+ {
+ result ^= bytes[j];
+ }
+ }
+ else if (m_pkValues[i] != null)
+ {
+ result ^= m_pkValues[i].hashCode();
+ }
}
m_hashCode = new Integer(result);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org