FetchEntity with PrefetchPath does not refresh child entities

Posts   
 
    
acl
User
Posts: 91
Joined: 28-Mar-2012
# Posted on: 19-Aug-2013 09:04:22   

We are using LLBLGen Pro Runtime Framework (Adapter) version 4.0.0.0.

When calling adapter.FetchEntity() on an entity that was previously fetched, its contents get updated.

However, when the entity has some child-entities that were fetched using a prefetchpath, these entities will not get updated (whether the prefetchpath is specified again in the adapter or not).

Illustration:


TCustomerEntity ety = New TCustomerEntity(1);
adapter.FetchEntity(ety, prefetch);

// another process changes the database values behind 
// TCustomerENtity and several Entities in the prefetchpath

// Refetch the entity to reflect these changes:
adapter.FetchEntity(ety, prefetch);

// Now the TCustomerEntity is updated, but the child entities are not

Is this normal? Is there an easy way around?

I don't like the idea of having to loop over the child entities explicitly. That would be one query for each one. Moreover, I would have to hard-code the prefetch path, so whenever I change it someplace, I'll have to update that piece of code as well.

I also cannot replace the entity objects, because there are references to them that I don't have control over.

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 19-Aug-2013 22:27:41   

Please use a Context. So whenever you fetch entities with or without prefetchPaths, you will only have one instance of any uique entity kept in the context which gets updated whenever you refetch in the same Context.