cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: Comparing objects
Date Fri, 20 Jun 2008 08:38:01 GMT
#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
>


Mime
View raw message