Right-click, Select Source-->Generate hashCode() and equals(). 

Pretty easy :-)

It should be pretty apparent how to fix it, just take out the offending
reference.

It lets you pick which fields you want to consider in the equality
comparison. If using Hibernate, you should use fields that form a
natural business key. DO NOT just compare IDs--read Hibernate in Action
for the reason.

Another thing--the Eclipse generated equals() code uses direct field
references to the other object rather than getters(). This does not work
reliably for Hibernate proxied objects. If you go through the getter,
the proxy will load the field if it hasn't be loaded yet, and the
comparison is correct. With direct field access, the proxy won't load
the real object. Very confusing the first time I saw this.

-----Original Message-----
From: Dean Jackson [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 22, 2007 11:50 PM
To: users@appfuse.dev.java.net
Subject: [appfuse-user] RE: Does Hibernate still require equals() and
hashCode()?



How do you get Eclipse 3.2+ to generate them?

Also, what's the easy correction for equals()?


Dennis Doubleday wrote:
> 
> Eclipse 3.2 generates them without a plugin. It also assumes the 
> superclass has a non-abstract equals, but it is easy to correct.
> 

-- 
View this message in context:
http://www.nabble.com/Does-Hibernate-still-require-equals%28%29-and-hash
Code%28%29--tf3275322s2369.html#a9113546
Sent from the AppFuse - User mailing list archive at Nabble.com.

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

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

Reply via email to