users@glassfish.java.net

Re: JPA, equals and hashCode

From: Stephen Connolly <stephen.alan.connolly_at_gmail.com>
Date: Wed, 19 Dec 2007 06:39:56 +0000

On Dec 19, 2007 12:48 AM, <glassfish_at_javadesktop.org> wrote:
> > Using @Id for hashcode is OK as long as you persist
> > objects before
> > putting them in a HashSet.
> >
>
> This sounds error prone to me.

Yep!
>
> >
> > How do you handle the case where business keys
> > change?
> >
>
> As a matter of fact, we haven't had to deal with this often. In the few cases where it's been an issue, we've used UUID. However, notice that the business "keys" don't have to be unique to be a good basis for hashCode.

No, but they do need to be constant