Running query "SELECT FROM org.datanucleus.test.A WHERE list.contains(this) PARAMETERS java.util.Collection list". If "list" Collection contains instance of type B (completely uncorrelated with A) and id of that instance happens to be the same of some other instance of type A query returns that instance of A. Supposedly the result should be always empty in such cases.
From Java Data Objects 2.2 spec, 14.6.2 "equality comparison among persistent instances of persistence-capable types use the JDO Identity comparison of the references; this includes containment methods applied to Collection and Map types. Thus, two objects will compare equal if they have the same JDO Identity."
Perhaps this can be prevented by filtering collection passed in as a parameter, leaving only types compatible with candidate classes.