DDC-2710: Defer Hydrating an entity until its fields are accessed when using getReference even if its associated entities are accessed #3452

doctrinebot opened this Issue Sep 27, 2013 · 2 comments

2 participants


Jira issue originally created by user anandagra:

I feel it should be beneficial to not hydrate an entity even if its associations are accessed, when using getReference to create the entity instance,

reason behind,
sometimes we have a lot of associations and we are only interested in loading one, and do not require any property (excluding associations) from that entity,

this could save us one sql query, unit it is needed,

Class User {
protected $id;
protected $username;
protected $password;


// one to many
protected $addresses;

$user = $em->getReference('..\User',1);
$user->getAddresses(); // this should only execute query against addresses table, and not to User table


Comment created by @beberlei:

While this would be cool, this sadly is not possible with PHP. We cannot detect this correctly.


Issue was closed with resolution "Can't Fix"

@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment