On 11/10/05, werner <[EMAIL PROTECTED]> wrote:

> I'm using OJB 1.0.3 with PB-API and it'S doing a great job. Now I'm
> looking for some information about the equals() and hashCode() methods:
> - In which cases should they be overwritten?

In general it is a good idea to overwrite these methods because
persistent objects (read from/written to a database) tend to have
value semantics, e.g. two objects are not only equal if they are
identical (as with the default equals implementation), but rather if
they have the same state (field values).

> - How can hashCode() be implemented? Can I use just the Primary Key for
> the hashcode, or does that cause problems?

You should only do that if your app controls the pk values. If OJB or
the database creates them, then this will cause problems with
yet-unwritten objects which obviously don't have pk values yet.

Tom

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to