martes, 25 de diciembre de 2012

Hibernate - hashcode / equals


Implementation of the methods equals and hashCode.



@Override
 public boolean equals(Object o) {
     if (this == o) return true;
     if (!(o instanceof Category)) return false;

      Category category = (Category) o;
     if (categoryName != null ?
             !categoryName.equals(category.categoryName) : category.categoryName != null) {
         return false;
     } else {
         return true;
     }
 }


 @Override
 public int hashCode() {
     return categoryName != null ? categoryName.hashCode() : 0;
 }

No hay comentarios:

Publicar un comentario