New Posts New Posts RSS Feed: QueryStrategy.DataSourceOnly doesn't work on related entities?
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

QueryStrategy.DataSourceOnly doesn't work on related entities?

 Post Reply Post Reply
Author
Dominique View Drop Down
Groupie
Groupie
Avatar

Joined: 28-Jun-2007
Location: Norway
Posts: 44
Post Options Post Options   Quote Dominique Quote  Post ReplyReply Direct Link To This Post Topic: QueryStrategy.DataSourceOnly doesn't work on related entities?
    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
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post 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..

 



Edited by davidklitzke - 08-Jul-2008 at 4:39pm
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down