On 2010-05-10 17.47, Stanislav Muhametsin wrote:
The test is this: public void script15() throws EntityFinderException { Male person = templateFor( Male.class ); // should return Ann and Joe Doe Iterable<EntityReference> entities = entityFinder.findEntities( Person.class.getName(), isNull( person.wife() ), NO_SORTING, NO_FIRST_RESULT, NO_MAX_RESULTS ); assertNames( entities, ANN, JOE ); }The test finds all people, who have their wife-association null. It assumes that it should return two values: Ann and Joe Doe. Looking at data models, the entity representing Ann Doe is of Female-type, and thus doesn't even have wife-association. So, how can "is null" query match something that doesn't even exist? At least I think that in order to be null, something must exist first.
The query is for any entity implementing Person, which includes Female/Ann. If the query asks for a property that doesn't even exist in the Ann instance, then Ann should be included, because it doesn't match the query requirement isNull(). So IMO the query/test is correct.
What is your opinion/explanation on this? Should there be separate "exists"-expression in queries? Or "is null" really should match non-existing things too?
I would say yes, isNull should match even non-existing things. If you compare to reality and ask all available Person instances (some of which are Male and some of which are Female), then it does make sense that all Females would be included. If you wanted to ask for Male that does not have Wife, then that is what the query would be.
/Rickard _______________________________________________ qi4j-dev mailing list [email protected] http://lists.ops4j.org/mailman/listinfo/qi4j-dev

