It's probably safe to compare objects that way since objects with the
same primary key (even before they've been assigned) should have the
same ObjectId. This should be equivalent to comparing primary keys.
If you want to compare everything but the primary key, then I'd
recommend iterating over the object attributes and comparing them that
way.
On 9/3/05, Gili <cowwo..bs.darktech.org> wrote:
>
> So you're saying it isn't safe to use
> this.getObjectId().equals(other.getObjectId()) to compare two objects.
>
> This question links to my previous discussion of
> getCanonicalInstance(). I want to compare the attributes *excluding* the
> primary key (since it is generated and meaningless).
>
> Gili
>
> Mike Kienenberger wrote:
> > In theory is the object-oriented equivalent to a primary key.
> > In practice, they're generally the same.
> > However, it's possible to have TemporaryObjectId subclasses for
> > objects that haven't had a primary key generated yet.
> >
> > It's also possible that in the future ObjectId could change to be
> > something else like a universal ID (pk + timestamp + ip address, etc)
> > to better support clustering.
> >
> > And ObjectID never changes, but an object can be assigned new
> > ObjectIds (I'm pretty sure that's what happens when a new object is
> > assigned a generated key, but I've never looked).
> >
> > -Mike
> >
> > On 9/3/05, Gili <cowwo..bs.darktech.org> wrote:
> >
> >>Hi,
> >>
> >> The implementation of ObjectId caches its hashcode because it says it
> >>is immutable. Does this mean that when a DataObject is modified in
> >>memory, it gets assigned a new ObjectId instance? It would be nice to
> >>mention this somewhere in the Javadoc. This is important because I'm
> >>wondering what ObjectId.equals() means ... it is important for end-users
> >>to know whether this simply compares the primary keys, the values of all
> >>the attributes, etc. Depending on what it does it will have different
> >>usefulness.
> >>
> >>Thank you,
> >>Gili
> >>--
> >>http://www.desktopbeautifier.com/
> >>
> >
> >
>
> --
> http://www.desktopbeautifier.com/
>
This archive was generated by hypermail 2.0.0 : Tue Sep 06 2005 - 12:24:33 EDT