Created
December 8, 2011 07:29
-
-
Save cakper/1446386 to your computer and use it in GitHub Desktop.
Doctrine not working eager loading
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$query = $em->createQuery('SELECT t FROM JazzyTransactionBundle:MoneyTransaction t WHERE t.sender = :user')->setParameter('user', $user); | |
$query->setFetchMode("JazzyTransactionBundle:MoneyTransaction", "sender", "EAGER"); | |
$transactions = $query->execute(); | |
WORKING: | |
<?php | |
$query = $em->createQuery('SELECT t FROM JazzyTransactionBundle:MoneyTransaction t WHERE t.sender = :user')->setParameter('user', $user); | |
$query->setFetchMode("Jazzy\TransactionBundle\Entity\MoneyTransaction", "sender", \Doctrine\ORM\Mapping\ClassMetadata::FETCH_EAGER); | |
$transactions = $query->execute(); |
"EAGER"
is not same as \Doctrine\ORM\Mapping\ClassMetadata::FETCH_EAGER
@vetalt: Thank you, Sir! This trolled me for a littel while.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah, even 3 years later I came across this same issue. setFetchMode() apparently requires a fully classified class name (FQCN) and not an alias shortcut - similar to the targetEntity attribute of association configuration.
Frankly I don't know why they bothered adding aliases for namespaces if you can't use them in half the places Doctrine expects a class name.