In M4, two proxies are equal if their stableId values are equal. This is convenient, but a little too equal and will lead to confusion and subtle bugs — proxies that have been made editable against different requests will be equal, and yet can have different property values:
does not imply that
Instead, they probably should be equal if they have the same stable id, and are bound to the same request, or are both bound to no request.
The tricky bit is making sure that proxies with this semantic don't become basically unusable to use with collections. e.g.:
So I have a Foo with a Set<Bar>, and it contains 1 Bar with ID 999. My test tries to remove this relation, so I do:
Fetch the FooProxy
Fetch BarProxy for ID 999
FooProxy.getSet().remove(barProxy); => will always fail silently
The only way to do the remove is to use an Iterator, implement your own check using stableId(), and call iterator.remove() when you find the match by stableId.