I have several entities defined in doctrine ORM that are used as a category 
tree structure. In most cases when a single one of these is loaded its 
parent and children will need to be loaded as well. I have a repository 
that loads the entire tree structure when fetching a category directly but 
when the category is loaded via an association on an entity doctrine, of 
course, only loads the specific category. I'd like to be able to make 
doctrine load the entire tree when it fetches any category. (This is 
especially useful since the repository makes use of Doctrine's result cache)

For instance, say I have an entity of type Size that is my category tree. I 
have a Book entity that has an association to Size. When I get the Book's 
size I want doctrine to call my repository method which will load all the 
sizes into memory rather than loading the individual size directly from the 
DB. I can get close to this behavior by adding a PostLoad event listener 
that loads all the categories after loading any one size but I'd like to 
get rid of the unnecessary DB call.

In short, is there some way of implementing a "PreLoad" event in doctrine 2 
ORM?

(I posters this on stackoverflow originally but I didn’t get any responses 
so I thought I’d try here. Thanks for any help!! 
http://stackoverflow.com/questions/25165109/how-to-load-all-entities-in-doctrine2-when-one-is-loaded-via-a-relationship
 
)

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