Solved by fixing the query as to look as:

class UserDoctrineORMRepository extends EntityRepository implements 
UserRepository {


    /**
     * Find a user by their email address
     *
     * @param Email $email
     * @return User
     */
    public function userOfEmail(Email $email)
    {
        return $this->_em->createQuery(
                'SELECT
                    u
                FROM OPP\Domain\Model\Users\User u
                WHERE
                    u.email.value = :email'
            )->setParameter('email', (string) $email)
            ->getResult();
    }


Quinta-feira, 28 de Agosto de 2014 10:39:47 UTC+1, [email protected] 
escreveu:
>
> I'm having trouble using dql with an embeddable property. Not sure if this 
> is the same issue as DDC-3154 
> <http://www.doctrine-project.org/jira/browse/DDC-3154>, of some hidden 
> configuration missing.
>
> I have the following simplified repository:
>
> <?php
>
> class UserDoctrineORMRepository extends EntityRepository implements 
> UserRepository {
>
>
>     /**
>      * Find a user by their email address
>      *
>      * @param Email $email
>      * @return User
>      */
>     public function userOfEmail(Email $email)
>     {
>         return $this->_em->createQuery(
>                 'SELECT
>                     u
>                 FROM OPP\Domain\Model\Users\User u
>                 WHERE
>                     u.email = :email'
>             )->setParameter('email', (string) $email)
>             ->getResult();
>     }
>
> }
>
>
> The following entity:
>
> <?php 
>
> /**
>  * @ORM\Entity
>  * @ORM\Table(name="users")
>  * @ORM\entity(repositoryClass="UserDoctrineORMRepository")
>  */
> class User {
>
>
>     /**
>      * @ORM\Id
>      * @ORM\GeneratedValue
>      * @ORM\Column(type="integer")
>      * @var UserId
>      */
>     private $id;
>
>
>     /**
>      * @ORM\Embedded(class="Email", columnPrefix=false)
>      * @var Email
>      */
>     private $email;
>
>
>     /**
>      * @ORM\Column(type="string")
>      * @var HashedPassword
>      */
>     private $password;
>
>
>     public function __construct(Email $email,
>         HashedPassword $password)
>     {
>         $this->email = $email;
>         $this->password = $password;
>     }
>
>
>     public function getId()
>     {
>         return $this->id;
>     }
>
>     /**
>      * @return Email
>      */
>     public function getEmail()
>     {
>         return $this->email;
>     }
>
>
>
> }
>
>
> And the Email value object:
>
> <?php
>
> /**
>  * @ORM\Embeddable
>  */
> class Email {
>
>
>     /**
>      * @ORM\Column(name="email", type="string")
>      * @var string
>      */
>     private $value;
>
>
>     /**
>      * Create new Email
>      *
>      * @param string
>      * @throws Assert\AssertionFailedException
>      */
>     public function __construct($value)
>     {
>         Assertion::email($value);
>
>
>         $this->value = $value;
>     }
>
>
>     /**
>      * Return the object as a string
>      *
>      * @return string
>      */
>     public function __toString()
>     {
>         return $this->value;
>     }
>
>
> }
>
>
> When I try using userOfEmail I got the following error:
>
>> [Semantical Error] line 0, col 124 near 'email = :ema': Error: Class User 
>> has no field or association named email
>
>
>  Thanks in advance.
>

-- 
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 post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to