title: Changing hashCode of object stored in hash-based collection
body: <p>I have a hash-based collection of objects, such as <code>HashSet</code> or <code>HashMap</code>. What issues can I run into when the implementation of <code>hashCode()</code> is such that it can change with time because it's computed from some mutable fields?</p>
  
  <p>How does it affect Hibernate? Is there any reason why having <code>hashCode()</code> return object's ID by default is bad? All not-yet-persisted objects have id=0, if that matters.</p>
  
  <p>What is the reasonable implementation of <code>hashCode</code> for Hibernate-mapped entities? Once set the ID is immutable, but it's not true for the moment of saving an entity to database.</p>
  
  <p>I'm not worried about performance of a <code>HashSet</code> with a dozen entities with key=0. What I care about is whether it's safe for my application and Hibernate to use ID as hash code, because ID changes as it is generated on persist.</p>