Hello,
could somebody help me to find out a way, how to use embedded objects in
custom queries? Is it somehow possible or I have to select each embedded
field one by one?
*Query:*
$variants = $entityManager
->createQueryBuilder()
->select('v.worldId, v.variantId')
->from(Variant::class, 'v')
->getQuery()
->getArrayResult();
*Exception:*
PHP Fatal error: Uncaught Doctrine\ORM\Query\QueryException: SELECT
v.worldId,v.variantId FROM Domain\Entity\Variant v in
/var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php:43
Stack trace:
#0 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(492):
Doctrine\ORM\Query\QueryException::dqlError('SELECT v.worldI...')
#1 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(765):
Doctrine\ORM\Query\Parser->semanticalError('line 0, col 9 n...', Array)
#2 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(272):
Doctrine\ORM\Query\Parser->processDeferredPathExpressions()
#3 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(360):
Doctrine\ORM\Query\Parser->getAST()
#4 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(286):
Doctrine\ORM\Query\Parser->parse()
#5 /var/www/html/vendor/doctrine/or in
/var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php on
line 65
*Entity mapping:*
<doctrine-mapping
xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"
>
<entity name="Domain\Entity\Variant" table="variants">
<id name="variantId" type="Domain_ValueObject_Variant_VariantId"/>
<embedded name="worldId"
class="Domain\ValueObject\Variant\VariantWorldId"/>
</entity>
</doctrine-mapping>
*Embedded mapping:*
<doctrine-mapping
xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"
>
<embeddable name="Domain\ValueObject\Variant\VariantWorldId">
<field name="ean" type="Domain_ValueObject_Ean_Nullable"/>
<field name="isbn" type="Domain_ValueObject_Isbn_Nullable"/>
</embeddable>
</doctrine-mapping>
Thank you
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/doctrine-user/e6f61d6d-0173-4fef-ac09-676edc4c27d1%40googlegroups.com.