As of the 5.2.2 release, the SessionImpl.equals(Object) method ignores the following advice recommended in the Java API documentation...
The equals method implements an equivalence relation on non-null object references:
It is reflexive: for any non-null reference value x, x.equals(x) should return true. It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true. It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified. For any non-null reference value x, x.equals(null) should return false.
Given a non-null instance, Session aSession — obtained through a call on SessionFactory.getCurrentSession() — the expected behavior of aSession.equals(aSession) should be a boolean return value of true. The actual behavior — as of the 5.2.2. release — is to confusingly return false. How "idiomatic" is it for a Java object to not be equal to itself? I confirmed this bug exists in 5.2.2 after asking this question in a Question-Answer forum |