I am using hibernate and need to override equals and hashCode(). I chose to use google-guava's equals and hashCode helpers.
I wanted to know if I am missing something here.
I have get/set methods for idImage and filePath.
@Entity
@Table(name = "IMAGE")
public class ImageEntity {
private Integer idImage;
private String filePath;
@Override
public int hashCode() {
return Objects.hashCode(getFilePath());
}
@Override
public boolean equals(final Object obj) {
if(obj == this) return true;
if(obj == null) return false;
if(obj instanceof ImageEntity){
final ImageEntity otherImage = (ImageEntity) obj;
return Objects.equal(getFilePath(), otherImage.getFilePath());
}
return false;
}
}
EDIT:
Ran into inheritance and have a sample here