How to Query with refresh including relations

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to Query with refresh including relations

Esteban A. Maringolo
Hi,

I have a simple object Tournament that has a ToMany relation with TournamentCategory, I want to be able to force the refresh of the Tournament and also the TournamentCategories.

If I do `alsoFetch: [:e | e categories]` it brings a _single_ category in the categories selection.

And it is not that I want to refresh each category, I want to refresh the whole list, since it might have changed since it was read (new/removed elements).

Is it possible? How do you do that?

Regards!

Esteban A. Maringolo

--
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/CAJMgPCJPRAXc3FV6F%3DOPTQ97Q6U0B2FogRByoJRWFw27tK9HMw%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: How to Query with refresh including relations

jtuchel
I guess you'd have to refresh all categires individually. like

self session refresh: tournament.
tournament categories do: [:c| self session refresh: c].

I am not aware of a "mass refresh" that could bundle these statements into one select, so each category will be read individually (meaning 7 select statements for one tournament and 6 categories). But looking at #refresh: I could imagine this is not too hard to implement, as long as the new refreshAll: is only used for collections of objects of the same Class. And with a few hours more you could probably group the ids by descriptors and bundle the selects...


Joachim


[hidden email] schrieb am Montag, 9. November 2020 um 01:27:23 UTC+1:
Hi,

I have a simple object Tournament that has a ToMany relation with TournamentCategory, I want to be able to force the refresh of the Tournament and also the TournamentCategories.

If I do `alsoFetch: [:e | e categories]` it brings a _single_ category in the categories selection.

And it is not that I want to refresh each category, I want to refresh the whole list, since it might have changed since it was read (new/removed elements).

Is it possible? How do you do that?

Regards!

Esteban A. Maringolo

--
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/21bb8aaa-74ac-4eb8-bda8-293d3a8cb131n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: How to Query with refresh including relations

Esteban A. Maringolo
On Tue, Nov 10, 2020 at 3:25 PM jtuchel <[hidden email]> wrote:
>
> I guess you'd have to refresh all categires individually. like
>
> self session refresh: tournament.
> tournament categories do: [:c| self session refresh: c].

That I could do of course, but the point is that the categories
collection might have changed, not just each category.

Since some stuff is loaded in another system and then synchronized via
an API, it might be the case that in my Glorp session I have five
categories, but then a new update/sync came in and now there are only
three, completely different from the other ones. So the right thing
would be to re-read the whole collection of the ToMany mapping.

> I am not aware of a "mass refresh" that could bundle these statements into one select, so each category will be read individually (meaning 7 select statements for one tournament and 6 categories). But looking at #refresh: I could imagine this is not too hard to implement, as long as the new refreshAll: is only used for collections of objects of the same Class. And with a few hours more you could probably group the ids by descriptors and bundle the selects...

I think that removing the objects in the collection (each category)
from the registered objects and forcing the re query/instantiation of
the collection defined by that mapping would work.
With a proxied collection this would be simpler because by freeing the
value of the proxy and setting it as not instantiated it would cause
it to automatically instantiate it again.
One of my first experiments when doing my own ORM was to have all
object references intermediated by proxies for this very reason.

At this point this is beer talk, but if there were another Camp
Smalltalk there are a lot of improvements that could come out of these
talks. :-)

Regards,

Esteban A. Maringolo

--
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/CAJMgPC%2BxRwE2hhX5owAhqUduOdhT1U_yjBzvVWgRcNTUoWzZWQ%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: How to Query with refresh including relations

Alan Knight
In reply to this post by Esteban A. Maringolo
My memories are getting pretty dusty at this point, but I think that what you're doing with the alsoFetch ought to work. The other option is you can send uninstantiate to the collection proxy, which would force it to re-query when accessed.

On Sun, Nov 8, 2020 at 7:27 PM Esteban Maringolo <[hidden email]> wrote:
Hi,

I have a simple object Tournament that has a ToMany relation with TournamentCategory, I want to be able to force the refresh of the Tournament and also the TournamentCategories.

If I do `alsoFetch: [:e | e categories]` it brings a _single_ category in the categories selection.

And it is not that I want to refresh each category, I want to refresh the whole list, since it might have changed since it was read (new/removed elements).

Is it possible? How do you do that?

Regards!

Esteban A. Maringolo

--
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/CAJMgPCJPRAXc3FV6F%3DOPTQ97Q6U0B2FogRByoJRWFw27tK9HMw%40mail.gmail.com.

--
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/CAGWHZ9-dy2LdpKi7wq6mkd%3DtZrzxeuWsttHtafh2Tww%3D4Zn%2BoA%40mail.gmail.com.