2017-11-06 18 views
0

작동하지 않습니다는 :심포니 3 - 교리 2 - oneToMany 관계에 해 orderBy 내가 두 엔티티 사이의 매우 간단한 <code>oneToMany</code>/<code>manyToOne</code> 관계가

Workflow 많은 States 원하는 분야

MyBundle\Entity\Workflow: 
    type: entity 
    id: 
    id: 
     type: integer 
     generator: {strategy: AUTO} 
    oneToMany: 
    states: 
     targetEntity: MyBundle\Entity\State 
     mappedBy: workflow 
     orderBy: 
     stateOrder: ASC 
     cascade: [all] 
     orphanRemoval: true 
     fetch: EAGER 
    ... 

많은 States 하나를 들고 Workflow :

MyBundle\Entity\State: 
    type: entity 
    id: 
    id: 
     type: integer 
     generator: {strategy: AUTO} 
    manyToOne: 
    workflow: 
     targetEntity: MyBundle\Entity\Workflow 
     inversedBy: states 
     cascade: [persist, merge, refresh] 
    ... 
    fields: 
    stateOrder: 
     type: smallint 

그러나 어느,112,또는 orderBy: DESC은 상태를 주문합니다. php bin/console doctrine:schema:update --force --complete --dump-sql을 실행하고 캐시를 지우고 옵션을 변경하면 아파치가 다시 시작되었습니다.

SELECT 
    t0.id AS id_1, 
    t0.name AS name_2, 
    t0.project_id AS project_id_3, 
    t4.id AS id_5, 
    t4.stateOrder AS stateOrder_6, 
    t4.workflow_id AS workflow_id_7, 
    t8.id AS id_9, 
    t8.keyWord AS keyWord_10, 
    t8.action AS action_11, 
    t8.workflow_id AS workflow_id_12, 
    t8.from_id AS from_id_13, 
    t8.to_id AS to_id_14, 
    t0.initialState_id AS initialState_id_15 
FROM 
    workflow_Workflow t0 
    LEFT JOIN workflow_State t4 ON t4.workflow_id = t0.id 
    LEFT JOIN workflow_Transition t8 ON t8.workflow_id = t0.id 
WHERE 
    t0.id = '10'; 

그래서 순서 : 여기


양식을 렌더링 할 때 실행 한 쿼리입니다 ... 같은 결과 orderBy: {'stateOrder': 'DESC'}/ orderBy: {'stateOrder': 'ASC'} :

나는 또한 orderBy 옵션을 추가하는 doctrines official way 시도 에 의해 쿼리의 일부가 아닙니다 ...

이것이 작동하지 않는 이유는 무엇입니까?

+0

특수 쿼리를 사용하여 해당 엔티티를 가져오고 있습니까? 만약 그렇다면 :'State' 엔티티가 페치 - 결합 되었습니까? – ccKep

+1

또한 [DDC-3448] (https://github.com/doctrine/doctrine2/issues/4256)과 관련된 것일 수 있습니다. – ccKep

+0

아니요, 엔티티가 Symfonys'ParamConverter'에 의해 자동으로로드됩니다 ...하지만 [github] (https://github.com/doctrine/doctrine2/issues/4256)에서 문제가 발견되었습니다 :'orderBy'가 작동하지 않습니다 'EAGER'! 어쨌든 고마워요 ... (당신은 어디에 문제를 신속하게 발견 할 수 있습니까?) – goulashsoup

답변