Re: Does Cayenne handle binary primary keys (Sybase) in relationships?

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Oct 22 2003 - 16:09:05 EDT

  • Next message: Andrus Adamchik: "Re: Does Cayenne handle binary primary keys (Sybase) in relationships?"

    Hi Michael,

    I think I might know what is causing the latest problem. ObjectId is
    used as a key to identify objects in the ObjectStore. So as a map key
    it must have a properly implemented hashCode() method. With String or
    numeric PKs hashCode() works since it relies on AbstractMap.hashCode()
    implementation. With byte[] it does not, since default hashCode for
    arrays of primitives seems to be based on identity rather than element
    equality. In fact I just wrote a test case that confirms my suspicion.

    I will do some more testing, and see how to create a smarter hashCode
    implementation. I'll keep you posted.

    > PS. Also, "80 80 80 80 80 80 80 A2 CC 20 EE C9" is different than
    > yesterday's "[0, 0, 0, 0, 0, 0, 0, 34, 76, -96, 110, 73]" ... 0x80 !=
    > 0. 0xA2 != 34 ...

    Umm, yeah... I am converting each byte to an unsigned form before
    converting it to HEX, by adding 128 (-Byte.MIN_VALUE). This does look a
    bit odd... I am open to suggestions on the logging format.

    Andrus



    This archive was generated by hypermail 2.0.0 : Wed Oct 22 2003 - 16:09:04 EDT