Hibernate version:3.1 Beta 2
Say I have this object:
Code:
public class ProviderType {
protected long id;
protected String desc;
...
With this equals method, uses a comparison of this.id and rhs.id
Code:
/**
* @see java.lang.Object#equals(Object)
*/
public boolean equals(Object object) {
if (object == this) { return true; }
if (!(object instanceof ProviderType)) { return false; }
ProviderType rhs = (ProviderType)object;
return new EqualsBuilder().append(this.id, rhs.id).isEquals();
}
When CGLIB has a proxy around it, rhs.id returns 0, whereas rhs.getId() returns the true id (which is not 0).
Changing the line to this:
Code:
return new EqualsBuilder().append(this.id, rhs.getId()).isEquals();
fixes it.
Has anyone seen this bug before, and know if this is an open issue with CGLIB?
Thanks,
gabe