Search code examples
phpinheritancejoindoctrine-ormdql

Access field of entity included in hidden join


Two entities, A and B, Bextends A. I'm interested in the field B.isOk. I have this query that joins A with other entities(and because B extends A, if I look at the pure sql, a join is done between A and B even though it is not specified in the query builder-because of the inheritance, great-). How can I then access that B.isOk if I only have A my query builder? I tried using INSTANCE OF but to no success.

In my yml for A there's specified :

inheritanceType: joined
discriminatorColumn:
  name: type
  type: text
discriminatorMap:
  internal-b: \C\BBundle\Entity\B

Any other suggestions on how could I use that property? I could add an extra join but what's the point since the join I need is already happening behind the curtains.


Solution

  • One alternative to this would be to give up DQL and write my own SQL query. since this can not be done because OOP principles, it means something might be wrong with my model so another solution would be to refactor the model and design a correct one that fits the current needs.