Re: Comparing objects

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri Jun 20 2008 - 04:38:01 EDT

  • Next message: Øyvind Harboe: "Re: Comparing objects"

    #3 is false. ObjectId *instances* are not unique, and require "equals"
    comparison.

    #1 & #2 are accurate.

    Andrus

    On Jun 20, 2008, at 11:34 AM, Øyvind Harboe wrote:

    > I'm wondering if I've gotten comparsion of objects right.
    >
    > Consider a, b both references to CayenneDataObjects.
    >
    > I want to know if a & b refer to the same row in a database.
    >
    >
    > 1. if (a==b)
    >
    > safe as long as a & b are in the same DataContext.
    > a & b can be garbage collected during the lifetime
    > of DataContext, but the above is still guaranteed to
    > work.
    >
    > 2. if (a.getObjectId().equals(b.getObject()))
    >
    > safe regardless of which DataContext the objects
    > are in.
    >
    > 3. if (a.getObjectId()==b.getObject())
    >
    > same as 2, except that it is faster.
    >
    >
    > If any of the above assumptions are false, then I need to
    > go into the application and fix it.
    >
    > --
    > Øyvind Harboe
    > http://www.zylin.com/zy1000.html
    > ARM7 ARM9 XScale Cortex
    > JTAG debugger and flash programmer
    >



    This archive was generated by hypermail 2.0.0 : Fri Jun 20 2008 - 04:39:03 EDT