title: discriminator in junction table with Doctrine
body: <p>I have a number of unrelated entities that I'd like to be able to add FileAttachment entities to.  I'm using Doctrine2 (in the context of a Symfony project).</p>
  
  <p>Before I started using Doctrine, I'd make a junction table with a discriminator column, like this:</p>
  
  <pre><code>file_id
  entity_id
  entity_type
  </code></pre>
  
  <p>So far as I can tell, with Doctrine I'll require a junction table for each entity type that has FileAttachment associations. I'd prefer to avoid that if possible. I found an NHibernate solution <a href="https://stackoverflow.com/q/23261022/128245">here</a>. Is it possible to do something similar with Doctrine and can anybody point me at some documentation? I've read (umpty times now!) chapters <a href="http://doctrine-orm.readthedocs.org/en/latest/reference/association-mapping.html#" rel="nofollow noreferrer">6</a> and <a href="http://doctrine-orm.readthedocs.org/en/latest/reference/inheritance-mapping.html" rel="nofollow noreferrer">7</a> of the Doctrine manual. But I'm not finding what I'm looking for. </p>