You are welcome. Natural keys are always preferable, but sometimes you don't
have one. Then you can add a UUID attribute, which is used for equals and
hashCode. You create the UUID when the object is created and then it is
never changed.
/Patrik


schmeling wrote:
> 
> You are right that's the problem, I found this also at 
> http://www.hibernate.org/hib_docs/v3/reference/en-US/html/persistent-classes-equalshashcode.html
> http://www.hibernate.org/hib_docs/v3/reference/en-US/html/persistent-classes-equalshashcode.html
>  
> 
> So each entity should have modeled at least one attribute that is a
> natural key or all attributes together should build the natural key.
> 
> Thanks a lot, that was a very important fact for me.
> 
> 
> Patrik Nordwall wrote:
>> 
>> How do you implement hashCode?
>> Consider the case when the object is placed in a Map before it is
>> persisted and then it is persisted. hashCode should not change.
>> 
>> /Patrik
>> 
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Hibernate-Cartridge%28CHB%29-Equals-Hashcode-ToString-tp20830500s17564p20912935.html
Sent from the Fornax-Platform mailing list archive at Nabble.com.


------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Fornax-developer mailing list
Fornax-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fornax-developer

Reply via email to