Using QueryBuilder and single table inheritance

Here's a quick tip on how to retrieve objects using the discriminator column with the QueryBuilder.

Let's imagine we want to retrieve the employees that holds the chef position in a restaurant. A raw SQL query would look something like:

SELECT * FROM employee WHERE position='chef'

When using Doctrine and single table inheritance, the discriminator column is not in the entity. In order to retrieve the same as the previous query but with the QueryBuilder, we'll need something like: