In ValidationContext$BeanAndPath we shouldn't rely on the hashCode() implementation of entities but rely on the actual object identity. This makes sure the logic works correctly also in case of collisions of the hashes from different objects, e.g. in cases where objects of different types have the same hash code.
Also see this post on SO, where the access to hashCode() causes an unwanted flush to the database.
|