EntityManager with createQuery()

With Symfony 3, I’ve often used the createQuery() function from the EntityManager so that I can use SQL statements.

Example:

$query = $em->createQuery("SELECT p FROM testcoreBundle:Product p JOIN p.productdetails d");

With the Update to Symfony 4 I need to change the entity. I tried the following but it doesnt work:

$query = $em->createQuery("SELECT p FROM :entity p JOIN p.productdetails d");
$query->setParameter('entity', Product::class);

Is there a way that I can still use full SQL statements with the QueryBuilder?