Print Page | Close Window

QueryStrategy.DataSourceOnly doesn't work on related entities?

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=877
Printed Date: 14-Sep-2025 at 3:20am


Topic: QueryStrategy.DataSourceOnly doesn't work on related entities?
Posted By: Dominique
Subject: QueryStrategy.DataSourceOnly doesn't work on related entities?
Date Posted: 08-Jul-2008 at 4:30am

Hi,

I am wondering if I am missing something. 

Use Case:

I have a parent-child relation. I fetch some parents with QueryStrategy.DataSourceOnly. I show the number of child using parent.Childs.Count. The db can be updated from others users or applications.

OK: 

If I insert/delete parent in the DB then they show up/disappear when I rerun the query.

BUT:

Children Count won't be updated if I insert new childs on existing parents in the DB

I get the same behaviour (not getting the lazy loaded child collection updated) if I show several properties of the children.

WORSE:

if I use a sapnQuery to get the childs eagerly then I wil get the new ones but it wan't remove the deleted one. This leads to several copies of the "same" entity.

this is a real problem when 2 different group of users works on the same datas (at different stage of a process) from diferent applications:

* UserRole1 register within ideablade app':

- Parent1 (child 1 and 2)

- Parent2 (child 3)

* UserRole2 later change the parent of a child from within another app' so that it is:

 - Parent1 (child 1)

 - Parent2 (child 2 and 3)

* userRole1 will then see:

 - Parent1 (child 1 and 2)

 - Parent2 (child 2 and 3)

This means that the "same" entity is present twice. (or is it only one collection that is not cleaned up?)

I am currently using Ideablade 3.5.4.1. Could you confirm this bug and if it is fixed in newer release of devforce?

--

Greetings 

Dominique



-------------
Dominique



Replies:
Posted By: davidklitzke
Date Posted: 08-Jul-2008 at 4:37pm

Dominique,

Actually. this all makes sense if you remember these simple rules:

(1) Every query has a Default Query Strategy (which may be overridden).

(2) The Default Query Strategy is Normal.

(3) The Normal Query Strategy looks to see if the query is in thw Query Cache.  If so, it finds the result in the Persistence Manager Entity Cache.  Otherwise it gets the result by querying the Databaase.

Now lets look at your cases:

Use Case:

Nothing unusual.

OK:

Nothing unusual.

But Children Count won't be updated.

This happens because we are using Normal strategy.  Query is found in the Query Cache, so we use Entity Cache, not database,

Worse, it wont' removed deleted entities from the Entity List.

That's because you need to use RefetchEntities iwhenever you want to remove the deleted items..

 




Print Page | Close Window