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:
$em = $this->getEntityManager('db'); $qb = $em->createQueryBuilder(); $qb->select('e') ->from('ProjectMyBundle:Employee', 'e') ->where('e INSTANCE OF ProjectMyBundle:ChefPosition')
The operator INSTANCE OF discriminate whether the employee holds a chef position or not, using the ChefPosition class.