Getting Graph

Posts   
 
    
alexvdb25
User
Posts: 2
Joined: 06-Sep-2010
# Posted on: 06-Sep-2010 13:04:24   

Hi,

Is there a way to automatically load the full graph for a particular entity by code?

I want to write a generic function which determines at run-time which related entities should be loaded....

Is this possible?

Thanks and best regards, Alex sunglasses

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 06-Sep-2010 15:26:49   

You should avoid loading the full graph as much as possible. This can lead to loading the entire database into memory.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 07-Sep-2010 17:49:51   

Perhaps you should elaborate it a bit more with an example

Frans Bouma | Lead developer LLBLGen Pro
howez
User
Posts: 28
Joined: 12-May-2007
# Posted on: 07-Sep-2010 20:30:12   

Alex,

This is possible, but here is how we are doing it. We have a generic rules engine where we use defined prefetch paths to graph an entity. The reason we used this approach is to avoid circular references. Additionally we had to define the starting point of the entity and for this we stored this information in a table so that only certain entities would be available.

Once it hits this generic method it will load up the appropriate prefetch path which in turn gives us the cleanest graph of the entity without the risk of running into circular references. Once you hit a circular reference you will run out of memory or very close to it.

The alternative to this method was to get all relations and then put in special cases that would attempt to catch every instance of a circular reference and then skip that particular relationship. This approach was abandoned in lieu of using prefetch paths.

I can give you more details on this approach if necessary, but it is possible and we are using it today.

Best,

jon

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 07-Sep-2010 21:10:46   

Jon's method is along the right lines - storing pre-defined prefetch paths for an entity is a much better bet that trying to generically load all related entities. On a database of any size this will cause major issues.

Matt