equals() and hashCode() can be implemented using this definition :

for all persistent objects a, b :
 a.equals(a)       ===     true 
 a.equals(b)       ==>     b.equals(a)  
 a.equals(b)       ==>     a.hashCode() = b.hashCode()    
 a is persistent   ==>     a.getId() != null
 a.equals(b)       <=>    a.getId().equals(b.getId())  
 a is persistent   ==>    a.hashCode() = a.getId().hashCode()



> 
> > 
> > This is more or less what commons-lang's reflectionToString 
> > does (which is what Gavin's patch will make the CodeGenerator do now)
> > 
> > But what about your hashCode ?
> > 
> > /max
> > 
> 
> I'm looking for advice on how to implement an equals() and hashCode()
> method in my base class.  Any suggestions are appreciated.
> 
> Thanks,
> 
> Matt
> 
> 
> 
> 
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> hibernate-devel mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/hibernate-devel



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to