title: Entity relation criteria in Doctrine2
body: <p>I have the AdminFiles entity which holds files for all project entities (news, pages, events etc.). It is structured (abridged) like this:</p>
  
  <pre><code>id          int(11) Auto Increment   
  entity      varchar(255) // this holds the entity name, e.g. Page or News
  entity_id   int(11) NULL // this holds the entity ID
  filename    varchar(1000) // this holds the path to the file
  </code></pre>
  
  <p>I would love to access the files in the entities (Page, News etc.) with something like $entity->getFiles(). But I'm having trouble creating the relation, since it is not only constrained by the ID, but also the entity name. Is there any way to join this inside the Doctrine2 entity, or do I have to do this in the service?</p>