Instead of
@Override
public boolean equals(Object obj)
{
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
final Location other = (Location) obj;
if (getId() != other.getId()) return false;
return true;
}
use
@Override
public boolean equals(Object obj)
{
if (this == obj) return true;
if (obj == null) return false;
if (! getClass().isAssignableFrom( obj.getClass() ) ) return false;
final Location other = (Location) obj;
if (getId() != other.getId()) return false;
return true;
}
Ref:
http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Class.html#isAssignableFrom(java.lang.Class)