Fixes CachingDatabase to return null on id lookups when there's a group constraint.

For example:

Query.fromAll().where("_id = 1"); // Article.
Query.from(Image.class).where("_id = 1"); // should be null but was Article before this fix.
Merge branch 'release/2.1' into release/2.2