This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
The netbeans-generated equals() and hashCode() methods only allow including the fields of the current class. Usually (or at least often) it is necessary to utilize those methods of the parent class to get a proper implementation. For example, netbeans generates this: public class Parent { private String a; @Override public int hashCode() { int hash = 7; hash = 53 * hash + (this.a != null ? this.a.hashCode() : 0); return hash; } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Parent other = (Parent) obj; if ((this.a == null) ? (other.a != null) : !this.a.equals(other.a)) { return false; } return true; } } public class Child { private String b; @Override public int hashCode() { int hash = 7; hash = 73 * hash + (this.b != null ? this.b.hashCode() : 0); return hash; } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Child other = (Child) obj; if ((this.b == null) ? (other.b != null) : !this.b.equals(other.b)) { return false; } return true; } } Here the hashCode() and equals() methods of Child should look more like this: @Override public int hashCode() { int hash = 7 + super.hashCode(); //THIS LINE IS MODIFIED hash = 73 * hash + (this.b != null ? this.b.hashCode() : 0); return hash; } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } if (!super.equals(obj)) { //THIS IF CLAUSE IS NEW return false; } final Child other = (Child) obj; if ((this.b == null) ? (other.b != null) : !this.b.equals(other.b)) { return false; } return true; }