@Override public boolean equals(Object obj) { if (obj == null) { return false; } Role role = null; try { role = (Role) obj; } catch (ClassCastException cce) { return false; } long primaryKey = role.getPrimaryKey(); if (getPrimaryKey() == primaryKey) { return true; } else { return false; } }