Add an ORM adapter which allows fetch joins #121
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The default ORM adapter does not allow queries where doctrine performs fetch joins (selecting additional entities via joins), because the normal result limit statements do not work there (it causes strange bugs like pages with only one row).
However doctrine offers the Pagiator class which can correctly determine page counts and elements for each page.
I wrote an adapter using doctrine paginator (extending the basic ORMAdapter) and because using fetch joins in more complex queries (to avoid the N+1 query problem) , I propose this adapter for the main repository.
I think a separate adapter is reasonable for this case, because the FetchJoinAdapter is slower than the normal adapter (because it have to perform 3 queries to determine the correct results) and it only supports object hydration mode, so a developer should explicitly choose to use this adapter.
This PR should also solve issue #93 .