-
Enhancement
-
Resolution: Done
-
Major
-
None
-
None
-
None
Domain classes generated by Forge need to override hashCode/equals if they are to be useful in a UI (among other places). This is hard to do if we know nothing about the semantics of the class, but the PersistencePlugin does know something: namely, the Id.
The following implementation would suffice for my purposes:
@Override
public boolean equals(Object that) {
if (this == that)
{ return true; }if (that == null)
{ return false; }if (getClass() != that.getClass()) { return false; }
if (id != null)
{ return id.equals(((Employer) that).id); } return super.equals(that);
}
@Override
public int hashCode() {
if (id != null)
{ return id.hashCode(); } return super.hashCode();
}
But I'm happy for other implementations too.