A per this Link
The gist of it is you only need to worry about it if your entity will be part of a Set(condition 1) or/And if you're going to be detaching / attaching its instances.(condition2)
As per my understanding we need only condition 1 where hashcode and equals method implementation is required
If i have a requirement where i don't want to store duplicate customer(based on customer name) or retrieve duplicate customers(for legacy data) from hibernate apis, then my understanding is storing customer under set does make sense here and it is the only scenario where we need to implement hashcode and equals method.
I do not understand how come hashcode and equal implementation helps when we are going to be detaching / attaching its instance(condition)
Update :- To confirm i tried re-attaching the detached instance like below
person detached instance lying here for id 1// person overrides hashcode and equals method
session = factory.openSession();
tx = session.beginTransaction();
person1=(Person)session.get(Person.class, 1);
session.lock(person, LockMode.NONE);// reattaching the detached instance here
// as per Marko Topolnik comment i was expecting equality will be checked based on equals and hashcode
// method but it was done based on person id . so question is does hashcode and equals come into picture
// while reattaching the detached instance
tx.commit();