I finally solved the problem. Thanks a lot!
The cause was indeed the implementation of the "equals" method. I was relying on a plugin called commonclipse that can generate toString(), equals(), hashCode() and compareTo() methods using the Jakarta Commons Lang package.
What I haven't notice, is that the code generated by this plugin for the equals method first calls super.equals(). When a class inherits directly from object, this call must be deleted, for the implementation of equals in Object is a pointer comparison (o1 == o2).
Code:
public boolean equals(Object object) {
if (!(object instanceof InvoiceHeader)) {
return false;
}
InvoiceHeader rhs = (InvoiceHeader) object;
return new EqualsBuilder()
.appendSuper(super.equals(object)) //<-- This was the problem!
.append(this.creationDate, rhs.creationDate)
.append(this.invoiceSequence, rhs.invoiceSequence)
.append(this.invoiceNumber, rhs.invoiceNumber)
.isEquals();
}
I hope this can help the other guys having similar problems.