db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker Identity.java
Date Sat, 20 Dec 2003 10:15:36 GMT
brj         2003/12/20 02:15:36

  Modified:    src/java/org/apache/ojb/broker Tag: OJB_BRANCH_1_0
                        Identity.java
  Log:
  fixed bug OJB230 (support for SQL-BINARY). patch by Dave Clark
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.28.2.1  +26 -7     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.28.2.1
  diff -u -r1.28 -r1.28.2.1
  --- Identity.java	28 Nov 2003 14:39:59 -0000	1.28
  +++ Identity.java	20 Dec 2003 10:15:36 -0000	1.28.2.1
  @@ -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;
   
  @@ -331,10 +332,16 @@
   
               result = getObjectsTopLevelClass().equals(id.getObjectsTopLevelClass());
               result = result && (m_pkValues.length == otherPkValues.length);
  +            
               for (int i = 0; result && i < m_pkValues.length; i++)
               {
  -                result = (m_pkValues[i] == null) ? (otherPkValues[i] == null)
  -                        : m_pkValues[i].equals(otherPkValues[i]);
  +                result = (m_pkValues[i] == null) ? (otherPkValues[i] == null) : m_pkValues[i].equals(otherPkValues[i]);
  +
  +                // OJB230 :SQL-BINARY maps to byte[] by Dave Clark
  +                if (!result && m_pkValues[i] instanceof byte[] && otherPkValues[i]
instanceof byte[])
  +                {
  +                    result = Arrays.equals((byte[]) m_pkValues[i], (byte[]) otherPkValues[i]);
  +                }
               }
           }
           else
  @@ -356,18 +363,30 @@
       public int hashCode()
       {
           // arminw:
  -        // identity is quasi immutable, thus
  -        // we can note hashCode
  -        if(m_hashCode == null)
  +        // identity is quasi immutable, thus we can note hashCode
  +        if (m_hashCode == null)
           {
               int result = getObjectsTopLevelClass().hashCode();
   
               for (int i = 0; i < m_pkValues.length; i++)
               {
  -                if (m_pkValues[i] != null) result ^= m_pkValues[i].hashCode();
  +                // OJB230 :SQL-BINARY maps to byte[] by Dave Clark
  +                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);
           }
           return m_hashCode.intValue();
       }
  +    
   }
  
  
  

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


Mime
View raw message