Fix issue with nested reference queries not being prepared properly.
Merge pull request #650 from doctrine/fix/prepare-nested-references

Fix issue with nested reference queries not being prepared properly.