What is difference between
In application 1 / 2:
$qb = $this->createQueryBuilder('tu');
$transUnits = $qb->select('tu, te')
->leftJoin('tu.translations', 'te')
->andWhere($qb->expr()->in('tu.id', $ids))
->andWhere($qb->expr()->in('te.locale', $locales))
->orderBy(sprintf('tu.%s', $sortColumn), $order)
->getQuery()
->getArrayResult();
and
$qb = $this->createQueryBuilder('tu');
$transUnits = $qb->select('tu, te')
->leftJoin('AppBundle:Translation', 'te')
->andWhere($qb->expr()->in('tu.id', $ids))
->andWhere($qb->expr()->in('te.locale', $locales))
->orderBy(sprintf('tu.%s', $sortColumn), $order)
->getQuery()
->getArrayResult();
The functions are called with the exact same parameters.
In the second case I replace 'tu.translations' with 'AppBundle:Translation' because do not recognize 'translations' where translations is define:
<one-to-many field="translations" target-entity="TranslationBundle\Entity\Translation" mapped-by="transUnit">
<cascade>
<cascade-all/>
</cascade>
</one-to-many>
In the first case result is: array(13) { ... } and this is the correct format result; in the second case wrong format result is: array(70) { ... }
I add in entity class:
/**
* @var \Translation
* @ORM\OneToMany(targetEntity="Translation", mappedBy="transUnit")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id", referencedColumnName="trans_unit_id")
* })
*/
protected $translations;
and
/**
* @var \TransUnit
*
* @ORM\ManyToOne(targetEntity="TransUnit", inversedBy="translations")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="trans_unit_id", referencedColumnName="id")
* })
*/
protected $transUnit;
And work. :)