title: Doctrine Join Many To Many without association
body: <p><strong>I have:</strong> two entities with undirectional M:M association.</p>
  
  <pre><code>class ShareInfo
  {
      // ...
  
      /**
       * @ORM\ManyToMany(targetEntity="Item")
       * @ORM\JoinTable(name="share_info_items",
       *      joinColumns={@ORM\JoinColumn(name="share_id", referencedColumnName="id")},
       *      inverseJoinColumns={@ORM\JoinColumn(name="item_id", referencedColumnName="id")})
       *
       * @var Item[]
       */
      private $items;
  }
  
  class Item
  {
      // ...
  
      // This entity has no association with ShareInfo,
      // because M:M is undirectional and defined in ShareInfo entity
  }
  </code></pre>
  
  <p><strong>What I want:</strong>
  Select data from items table (Item entity), where at least one M:M record between Item and ShareInfo exists.</p>
  
  <p><strong>My suggestion which doesn't work (I've got a semantic error)</strong>:</p>
  
  <pre><code>$queryBuilder
      -&gt;select('i')
      -&gt;from(Item::class, 'i')
      -&gt;innerJoin(ShareInfo::class, 'shareInfo', 'WITH', 'shareInfo.items = i');
  </code></pre>
  
  <p>In pure SQL I'd do something like this:</p>
  
  <pre><code>SELECT i.*
  FROM items i
  INNER JOIN share_info_items shareInfo
      ON shareInfo.item_id = i.id
  </code></pre>
  
  <p>Can't believe there is no DQL analog for this. The only solution I can imagine is to split undirectional M:M association into bi-directional</p>
  
  <p>P.S. This question has no duplicates, I checked well.</p>