Using auto generated id of Hibernate entity object in the equals and hashcode methods
问题 Lovely equals and hashcode, all the theory is here and also here I have taken the decision to use the auto-generated id within equals() and hashcode() in a number of my hibernate entity/domain objects. However, a number of websites say you should never do this due to the risk of persisting an object to the database for the first time whilst it is in the process of being compared or using hashcode. My point of view is that in most use cases this is much more unlikely than any other field being