prefetchPath and relations

Posts   
 
    
Wally
User
Posts: 285
Joined: 29-Aug-2007
# Posted on: 26-Mar-2008 14:14:27   

Hi,

We have made some tests and would appreciate to have some light on some results.

As far as I understand, - prefetchPath is used to defined wich fields should be returned (part of the SELECT portion of the query). - relations are used to define the filter (part of the JOIN and WHERE clause) but does not imply any returned entities at all (would not load in memory entites imply in the relations if they are not included in the prefetchPath).

It appears to me that I can't filter on any fields on prefetchedPath if they are not included as a relation. You will tell me that is a choice made for effiency... to separate returned fields from filters. I understand that point, but I wonder what could restrict us from being able to set filter on prefteched path also ?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 26-Mar-2008 14:31:11   

As far as I understand, - prefetchPath is used to defined wich fields should be returned (part of the SELECT portion of the query). - relations are used to define the filter (part of the JOIN and WHERE clause) but does not imply any returned entities at all (would not load in memory entites imply in the relations if they are not included in the prefetchPath).

I'll have to correct you a little bit on the above:

1- PrefetchPaths don't fetch defined fields as part of the original Select Query. Rather it fetches each set of related entities in another Select Query.

eg. If you want to fetch a collection of Customers and their related Orders (the Orders related to each customer in the collection).

2 queries will be executed if you use a PrefetchPath to fetch Orders with Customers. 1st Query to fetch Customers. 2nd Query to fetch all Orders related to all the above Customers.

Then LLBLGen Pro associate each set of Oreders to their related specific Customer in the customer.Orders collection.

2- Relations are simply JOINS 3- Predicates are WHERE Clauses (Filters) 4- You may use Relations and Predicates to filter the fecthed Collection. 5- You may also use them to filter a prefetched Collection.

Wally
User
Posts: 285
Joined: 29-Aug-2007
# Posted on: 26-Mar-2008 14:36:44   

Thanks Walaa, it confirm my thought ! ... I have another thread related to this... that you probably have red now simple_smile