Implementing equals and hashCode for objects with circular references in Java
I agree with the comment of I82Much that you should avoid having B referencing their parent: it’s information duplication, which usually only leads to trouble, but you might need to do so in your case. Even if you leave the parent reference in B, as far as hash codes are concerned you should completely ignore … Read more