Community Page
- www.brodwall.com/johannes/blog/ Jump to website »
-
Subscribe -
Community
-
Top Commenters
-
Popular Threads
-
Recent Comments
- The evolution of SOA Introduce the concepts of services and SOA Design principles of SOA ... The benefits of employing SOA Review of common business goals ... Related articles. Web Application...
- Great article and I agree with you that ............ Thanks for the tips!
- Great read, good work old chap :)
- Hi...Your post really got me thinking man..... an intelligent piece ,I must say.
- Was a good read. thank great post, I think this article is useful. I'll be back for more. Thanks for sharing the information . .. :)
Jump to original thread »
What you didn't think you needed to know about hashCode and equals
Started by jhannes · 8 months ago
This article is a repost of my comments to the question on how to implement hashCode and equals on stackoverflow
There are some issues worth noticing if you’re implementing hashCode and equals for classes that are persisted using an Object-Relationship Mapper (ORM) like Hibernate. ... Continue reading »
There are some issues worth noticing if you’re implementing hashCode and equals for classes that are persisted using an Object-Relationship Mapper (ORM) like Hibernate. ... Continue reading »
8 months ago
If you declare that id shouldn't be used in hashCode; in the same way you could say that you cannot use any fields in hashCode, as every one of those can change.
Surrogate should be the most stable property of an persist entity as it changes only once.
Great post though, too few have been written on the subject.
8 months ago
The example wasn't very clear. I've run into the the problem in the following situations: I have a Parent object that includes many Children in a HashSet. I construct a new Parent and add Children to it, then I persist the Parent for the first time, and the HashSet is configured persisted as well, through cascading.
The result is that the Child objects are given an id, their hashCode change, and I can no longer find them.
Hope this was clearer?
8 months ago
In a framework I have used, persistent keys were (wastefully) created with the object, so even if the object would never be persisted, it still had a PK. So one could use the PK in hashcode implementations.
8 months ago
8 months ago