Login  Register

Filling a Collection with alsoFetch: still materializes Proxies...

Posted by jtuchel on Nov 04, 2020; 7:09am
URL: https://forum.world.st/Filling-a-Collection-with-alsoFetch-still-materializes-Proxies-tp5124357.html

Hi there,

I have this weird thing I don't understand. For a GUI component I issue a query like this (very simplified):

q := SimpleQuery read: Garage where: [:g| g cars anySatisfy: [:c| color = 'silver']].
q alsoFetch: [:g| g car wheels asOuterJoin].

myCarCollection := self session execute: q.

Obviously, I am talking about a OneToManyRelationship here.

So once this collection of cars is read from the database, it is displayed in a list to the user. IN the list I want to display whether the car has wheels or not.

Now to the "funny" effect. Each car will then issue an SQL statement like this whenever the getter #cars of a Garage is accessed:

SELECT t1.id, ...
FROM WHEEL WHERE CAR_ID = "the id of a car"

So it seems that even though my initial search/query joins the Garage, Car and Wheel table, the cars will hold a Proxy in their wheels inst var.

In our not so simple productive case, this means that some lists take a long time to render because it issues a few hundred SQL statements for data that has already been read in the first query.

I already tried tried #shouldProxy: false in the OneToManyMapping for the car's wheels attribute, but to no avail. Even adding the alsoFetch: to the Garage's #cars mapping doesn't avoid these extra SQLs. (and it may be a tricky optimization that strikes back whenever the wheels of cars in a garage aren't needed....)

Any ideas what I can do?


Joachim









--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/glorp-group/04df8996-dc80-4be8-b034-c7ebf047532en%40googlegroups.com.