Re: Add getHashCode() to CayenneDataObject?

From: Kevin Menard (kmenar..ervprise.com)
Date: Wed Jun 21 2006 - 12:11:19 EDT

  • Next message: Andrus Adamchik (JIRA): "[JIRA] Created: (CAY-576) Support for cached lists invaldation"

    On Wed, 21 Jun 2006 11:58:07 -0400, Gentry, Michael (Contractor)
    <michael_gentr..anniemae.com> wrote:

    > Would it make sense to add:
    >
    > public int getHashCode()
    > {
    > return getObjectId().hashCode();
    > }

    > Any thoughts on this? Or is there another way to get a unique value for
    > an object that doesn't expose the entity/keys? If only Java let me get
    > the pointer (I miss &).

    My only concern is expanding the code to work with DOs that aren't yet
    registered with a DC. In that case, the OID is null, so the above code
    breaks. In order to not break the equals() contract though (I'm assuming
    you want getHashCode() to work similarly to hashCode()), you just have to
    be careful how you deal with null values. In particular, two DOs created
     from different classes, both with null OIDs probably shouldn't have the
    same hash code.

    -- 
    Kevin
    



    This archive was generated by hypermail 2.0.0 : Wed Jun 21 2006 - 12:11:43 EDT