使用 knp 分页器的实体中的复合主键不允许使用单个 id
Single id is not allowed on composite primary key in entity using knp paginator
我有一个关于 knp paginator 的问题。
我使用 Symfony 2.8。
我使用 knp 分页器制作了一个具有复合主键和相应列表页面的 table。
当我尝试显示时收到异常。
"Single id is not allowed on composite primary key in entity"
我试图检查 knp paginator 和 doctrine 的源文件。
所以我找到了解决方法。
1)设置knp选项"distinct"为false;
2)设置查询提示如下
- 设置"knp_paginator.count"为查询结果的行数。
- 将 "knp_paginator.fetch_join_collection" 设置为 false -- 这是必要的。
这是正确的方法吗?
是否存在潜在问题?
您可能遇到的问题已发布在 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.
我有一个关于 knp paginator 的问题。 我使用 Symfony 2.8。 我使用 knp 分页器制作了一个具有复合主键和相应列表页面的 table。 当我尝试显示时收到异常。 "Single id is not allowed on composite primary key in entity" 我试图检查 knp paginator 和 doctrine 的源文件。 所以我找到了解决方法。
1)设置knp选项"distinct"为false;
2)设置查询提示如下
- 设置"knp_paginator.count"为查询结果的行数。
- 将 "knp_paginator.fetch_join_collection" 设置为 false -- 这是必要的。
这是正确的方法吗? 是否存在潜在问题?
您可能遇到的问题已发布在 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.