documentation about hashcode and equals not up to date

Description

You explain at https://docs.jboss.org/hibernate/orm/5.0/manual/en-US/html/ch04.html#persistent-classes-equalshashcode how to write equals and hashcode.
Current java versions allow to implement these methods in much shorter and cleaner code using java.util.Objects.equals() and java.util.Objects.hash().

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 @Override public boolean equals(Object rhs) { if (this == rhs) return true; /** * A proxy class does not compare well. So we first have to get the real * class */ if (rhs == null || Hibernate.getClass(this) != Hibernate.getClass(rhs)) return false; MyClass that = (MyClass ) rhs; if (!java.util.Objects.equals(fieldname, that.fieldname)) return false; return true; } @Override public int hashCode() { return java.util.Objects.hash(fieldname); }

Environment

every

Status

Assignee

Vlad Mihalcea

Reporter

Carsten Hammer

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.0.0.Final

Priority

Minor