This is exactly how proxies are supposed to work:

When Doctrine "lazy" fetches an association, it will create proxies in stead of 
real entities. The only data known in the proxy is the identifier.

When you call any method on that proxy, it will load itself (a query is 
performed to fetch the data), and you'll get results as if it where a real 
entity. In fact, you can view a loaded proxy as a real entity.

If you don't want Doctrine to create proxies in a certain case, you should 
"eager" fetch the association. This can be done with a DQL query, or by marking 
the association as eager (fetch="EAGER" in the mappings).
I recommend using DQL in the cases where you actually need the association to 
be loaded.

-- 
Jasper N. Brouwer
(@jaspernbrouwer)


On 15 October 2014 at 09:52:09, Giulio Provasi ([email protected]) wrote:
> Ok it seems that Doctrine act really weird:
> 
> if I do: *$event->getUser()* it returns a PROXY object with only the PK set
> and the rest of fields are null, but if I do *$event->getUser()->getLogin()* I
> get the correct result.
> 
> Isn't there a way to "load" the proxy once the getter invoked from the
> associated class ?


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