Take two classes, FooA and FooB, both of which implement IFoo and contain a Set<IFoo>. Now create an instance of FooA and an instance of FooB, then add the FooB to the FooA's set and persist it. Clear your caches (or close your program and reopen it), then query the datastore and find the instance of FooA you just persisted. Get the FooA's set of IFoo and ask if it contains the instance of FooB. The set will report that it does NOT contain the FooB, even though it actually does.
The problem appears to be related to caching and SCO wrappers. The set will correctly report that it contains the FooB if the instance of FooB is in the cache. I have, therefore, been able to work around this problem in two ways:
- marking the set as being part of the default fetch group
- calling the set's iterator() method before calling the set's contains() method