Hi Sander,

IS EMPTY can be used for collections (xToMany). For entities (xToOne) you can 
use IS NULL.

-- 
Jasper N. Brouwer
(@jaspernbrouwer)


On 5 August 2014 at 10:36:13, Sander Marechal ([email protected]) wrote:
> Hello,
> 
> How can I query for an empty, optional one-to-one association? In my
> domain model I have an object which may or may not have another object.
> Example:
> 
> /**
> * @ORM\Entity
> */
> class Foo
> {
> /**
> * @ORM\OneToOne(targetEntity="Bar",
> * mappedBy="foo", orphanRemoval=true
> * )
> */
> private $bar;
> }
> 
> /**
> * @ORM\Entity
> */
> class Bar
> {
> /**
> * @ORM\OneToOne(targetEntity="Foo", inversedBy="bar")
> * @ORM\JoinColumn(name="foo_id", referencedColumnName="id")
> */
> private $bar;
> }
> 
> I would like to find all instances of Foo that do not have a Bar yet.
> Sadly, this doesn't work:
> 
> SELECT Foo f WHERE f.bar IS EMPTY
> 
> Any ideas? Kind regards,
> 
> --
> Sander Marechal


-- 
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