[DDC-2213] Paginator does not work with composite primary key entity Created: 25/Dec/12 Updated: 15/Aug/13
|Project:||Doctrine 2 - ORM|
|Reporter:||Stanislav Anisimov||Assignee:||Benjamin Eberlei|
|Labels:||composed, key, paginator|
Paginator does not work with composed primary key.
"Single id is not allowed on composite primary key in entity" exception is thrown here
Only first column values are fetched while retrieving primary keys here
|Comment by Marco Pivetta [ 23/Jan/13 ]|
Limitation was confused by issue reporter and considered bug
|Comment by Austin Morris [ 15/Aug/13 ]|
I'd like to add some additional information because the title and description are misleading.
Paginator does work with composite primary key entities. You just cannot use the Paginator when your query does a fetch join with a collection (a one-to-many or many-to-many association). See the documentation for a brief description:
In order to use Paginator with a composite primary key entity, you need to instantiate the Paginator with the $fetchJoinCollection flag set to false (it defaults to true). Now, pagination will skip the WhereInWalker which throws an exception when using a composite primary key. Fetch joins with entities (one-to-one or many-to-one) will still work. You can even use a regular join with a collection.
The only "problem" is when your Paginator query calls for a fetch join to a collection. The work around for this is to use a regular join as mentioned above. The drawback is that your paginated entities will not be hydrated with the collection. The collection will have to be lazy-loaded when called upon.