Remove the object you want to modify from the set, modify it, and then add it back. As far as I know, there is no standard implementation Setthat can handle fields (which are used in the implementation hashCode()or compareTo()) that change when saved.
Alternatively, if the fields are not used to determine identity, equality or location (i.e. are not used in hashCode(), compareToor equals()), then there is no problem.
source
share