Symfony & Doctrine InnerJoin
<p>I'm trying do a join with doctrine query builder.</p>

<pre><code>$query = $this-&gt;createQueryBuilder('od');
$query-&gt;innerJoin(Order::class, 'o', Expr\Join::WITH, 'o.orderid = od.orderid');
$query-&gt;where('o.userid = :userid')
$query-&gt;andWhere('od.orderstatusid IN (:orderstatusid)')
$query-&gt;setParameter('userid', $userid);
$query-&gt;setParameter('orderstatusid', array(5, 6, 7, 8, 10))
</code></pre>

<p>The request failed because the generate SQL is :</p>

<pre><code>SELECT od FROM OrderDetail od INNER JOIN Order o WITH o.orderid = od.orderid WHERE o.userid = :userid AND od.orderstatusid IN (:orderstatusid)
</code></pre>

<p>Or it should be </p>

<pre><code>SELECT od FROM OrderDetail od INNER JOIN Order o ON o.orderid = od.orderid WHERE o.userid = :userid AND od.orderstatusid IN (:orderstatusid)
</code></pre>

<p>I cant use $query->innerJoin(Order::class, 'o', Expr\Join::ON, 'o.orderid = od.orderid'); because i got this error :</p>

<pre><code>[Syntax Error] line 0, col 91: Error: Expected Doctrine\\ORM\\Query\\Lexer::T_WITH, got 'ON'
</code></pre>

<p>If i dont use join condition, doctrine doesnt get it from the model so i dont have the good results.</p>

<p>How can you have a join and a where with querybuilder ?</p>

<p>Thanks for your help</p>

<p>Edit :
This is the model :</p>

<pre><code>OrderDetail:
    type: entity
    table: order_detail
    repositoryClass: OrderDetailRepository
    id:
        orderdetailid:
            type: integer
            nullable: false
            options:
                unsigned: false
            id: true
    fields:
        ...
    lifecycleCallbacks: {  }
    manyToOne:
        order:
            targetEntity: Order
            inversedBy: orderdetails
            joinColumn:
                name: orderid
                referencedColumnName: orderid


Order:
    type: entity
    table: order
    id:
        orderid:
            type: integer
            nullable: false
            options:
                unsigned: false
            id: true
    fields:

    lifecycleCallbacks: {  }
    oneToMany:
        orderdetails:
            targetEntity: OrderDetail
            mappedBy: order
            fetch: EAGER
</code></pre>