Re: Comparing EOs
Re: Comparing EOs
- Subject: Re: Comparing EOs
- From: "Jerry W. Walker" <email@hidden>
- Date: Wed, 29 Mar 2006 09:34:43 -0500
Hi, Miguel,
On Mar 29, 2006, at 9:04 AM, Miguel Arroz wrote:
Something I could still not figure out from the docs... what is
the standard implementation of the "equals" method in EOs? How does
WebObjects compare objects if I do not implement the equals method?
The documentation for EOCustomObject says the following:
=========================================
equals - public final boolean equals(Object other)
EOF requires all EOs define equality as (this == other) To compare
EOs in different EOEditingContexts, consider instead comparing their
EOGlobalIDs with equals()
=========================================
Although the grammar isn't the best, it's pretty clearly saying that
if you don't override the equals method, it compares for object
equality (that is, it tests whether both the message recipient
reference and the argument object reference are references to the
same object instance).
The sentence that starts, "To compare EOs in different
EOEditingContexts, ...", is simply suggesting a more effective
implementation to compare EOs across editing contexts if you care to
override the method. The suggestion is a good one, since two EOs from
different editing contexts will be different objects, even if they
represent the same record from the database. By comparing
EOGlobalIDs, you will effectively test whether they represent the
same persisted object rather than testing whether they are the same
instance of an object.
Regards,
Jerry
--
__ Jerry W. Walker,
WebObjects Developer/Instructor for High Performance Industrial
Strength Internet Enabled Systems
email@hidden
203 278-4085 office
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden