This is more or less what can be expected. The root cause is that your implementation is breaking the rules in the contract for the Set interface. This is from the java documentation:
Quote:
Note: Great care must be exercised if mutable objects are used as set elements. The behavior of a set is not specified if the value of an object is changed in a manner that affects equals comparisons while the object is an element in the set.
Since the hash code is part of equals comparisons it is not allowed to change the hash code of an object while it is in a set. This problem is also discussed in the Hibernate documentation
http://docs.jboss.org/hibernate/core/3. ... lshashcode which also gives one possible solution.