I have just upgraded to 1.0.rc5 from 1.0.rc4. I no longer get a fully populated object graph on retrieval. The problem is caused by the Identity.equals method, which returns false instead of true.

All our primary keys map to an attribute of type byte[]. The equals method for byte[] does not compare content. To solve the problem, I have replaced this with a call to an equals method that looks at content for a byte[].

 Here is the changed code. 

           for (int i = 0; result && i < m_pkValues.length; i++)

           {

           // <.avk> changed to cater for byte[] <./avk>

                       result =

                                   (m_pkValues[i] == null)

                                   ? (otherPkValues[i] == null)

                                   : isEqual(m_pkValues[i], otherPkValues[i]);

           // commented out by avk  : m_pkValues[i].equals(otherPkValues[i]);

           } 

/**

 * <.avk> Method added <./avk>

 * Special consideration is given to byte[].

 * PreCondition: Check already done for not null

 */

           private boolean isEqual(Object obj1, Object obj2)

           {

           boolean isEqual = false;

           // If we have a byte array

           if (byte[].class.isInstance(obj1))

           {

                       isEqual = ByteArrayUtil.isEqual((byte[]) obj1, obj2);

           }

           else

           {

           isEqual = obj1.equals(obj2);

           }

           return isEqual;

}

ByteArrayUtil.isEqual  checks the content of each byte for equality

With this change, the object graph is retrieved correctly.

Wishing you all the best for 2004

Avril

 

________________________________________________________

  

 

Reply via email to