问题
I have a question about knp paginator. I use Symfony 2.8. I made a table that has composite primary key, and corresponding list page using knp paginator. I'm receiving the exception when I try to show. "Single id is not allowed on composite primary key in entity" I tried to inspect source files of knp paginator and doctrine. So I found a workaround.
1)Set knp option "distinct" to false;
2)Set following hints to query.
- set "knp_paginator.count" to rows count of query result.
- set "knp_paginator.fetch_join_collection" to false -- this is neccessary.
Is this right way? Are there potential problems?
回答1:
The problem you might encounter is posted here in this related issue on GitHUB:
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.
来源:https://stackoverflow.com/questions/39542653/single-id-is-not-allowed-on-composite-primary-key-in-entity-using-knp-paginator