Description:
|
I have a Map where both the key and value are entities.
When I try to modify the map (for example, by adding an element to it), all but one of my map entries get deleted.
The two things necessary to reproduce it seem to be:
(1) The key entity has a many-to-one foreign key relationship to the value entity
(2) Both key and value entities implement equals() and hashCode(), using the unique key fields for the class
If I remove either of the above, the code works fine.
It seems to be adding my entities to the map before initializing them, so equals() always returns true (all of the unique key fields are null).
I have attached a test case that reproduces the issue.
|