title: How to JOIN without a relationship in Doctrine?
body: <p>I have an entity <code>Log</code> (table <code>log</code>) with members <code>resourceType</code> and <code>resourceId</code> (with columns <code>resource_log</code> and <code>resource_id</code>). The <code>resourceType</code> can e.g. <code>Order</code> (for actions on orders, e.g. status changes ) or <code>Whatever</code> (for <code>Whatever</code> related actions). There is no relationships (neither in Doctrine, nor in the database) between the <code>Log</code> and the "resource" entities/tables.</p>
  
  <p>Now I want to select only the <code>Log</code>s, that are related to <code>Order</code>s with <code>myOrderProperty = "someValue"</code>. That means:</p>
  
  <pre><code>SELECT
      *
  FROM
      `log`
  JOIN
      `order` ON `order`.`id` = `log`.`resource_id` AND `log`.`resource_type` = 'order'
  WHERE
      `order`.`my_order_property` LIKE '%my_order_property_value%'
  </code></pre>
  
  <p>But the code</p>
  
  <pre><code>$queryBuilder = $this-&gt;entityManager-&gt;createQueryBuilder();
  $queryBuilder-&gt;select('l')-&gt;from(Log::class, 'l');
  $queryBuilder-&gt;join('l.order', 'o');
  ...
  $queryBuilder
      -&gt;where('o.myOrderProperty = :myOrderProperty')
      -&gt;setParameter('myOrderProperty', $myOrderProperty);
  </code></pre>
  
  <p>doesn't work, since the entity <code>Log</code> doesn't have any relationship with the <code>Order</code> (though it has a property <code>order</code>):</p>
  
  <pre><code>[Semantical Error] line 0, col 102 near 'o WHERE o.myOrderProperty': Error: Class MyNamespace\Log has no association named order
  </code></pre>
  
  <p><strong>How to <code>JOIN</code> without a relationship defined between two entities?</strong></p>
  
  <p><sub>I know, I could use <a href="http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/inheritance-mapping.html" rel="noreferrer">inheritance</a>. But semantically it's not an inheritance case. So is there another way for solving the problem?</sub></p>