Comparing objects

From: Øyvind Harboe (oyvind.harbo..ylin.com)
Date: Fri Jun 20 2008 - 04:34:40 EDT

  • Next message: Andrus Adamchik: "Re: Comparing objects"

    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:35:12 EDT