For our JPA entities we are overriding the equals and hashCode methods. I think the definitions are generated by Netbeans (I don't usually include equals or hashCode in my entities personally, but our other developers do)
I haven't ever encountered a problem in our application by not including these methods so I am wondering if I should just remove them.
If this is a really bad idea, then how thoroughly do I need to test the equals() method? Am I going to need to write tests for each of the conditions in the equals() contract ? For example a test for each of the following:
Reflexive: for any reference value x, x.equals(x) should return true.
Symmetric: for any reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
Transitive: for any 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.
Consistent: for any 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 object is modified.
For any non-null reference value x, x.equals(null) should return false.