Fixes query so that it won't assume all attributes of entity has values.
Fixes resolving referenced objects when requested.