Eager loading by default possible ?

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

Eager loading by default possible ?

Jan van de Sandt
Hello list,

With a query you can use the alsoFetch:  method to "eager load" related objects. Is it possible to specify a mapping so that Glorp does this by default?

My Model is something like this:

Class A ----(*)--> Class B ----(1)--> Class C

Class A has a collection of B instances and each B instance refers to exactly one C instance. What I would like to have is that when Glorp loads the the collection of B instances for an A instance it also loads the C instances using a join query.

Cheers,
Jan.

--
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 post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
To view this discussion on the web visit https://groups.google.com/d/msgid/glorp-group/212f6892-ae48-479b-b411-b149494208d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Eager loading by default possible ?

Alan Knight
Yes, it's definitely possible. Look for sends of alsoFetch: inside descriptors in the tests.

On Thu, 6 Jun 2019 at 09:31, Jan van de Sandt <[hidden email]> wrote:
Hello list,

With a query you can use the alsoFetch:  method to "eager load" related objects. Is it possible to specify a mapping so that Glorp does this by default?

My Model is something like this:

Class A ----(*)--> Class B ----(1)--> Class C

Class A has a collection of B instances and each B instance refers to exactly one C instance. What I would like to have is that when Glorp loads the the collection of B instances for an A instance it also loads the C instances using a join query.

Cheers,
Jan.

--
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 post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
To view this discussion on the web visit https://groups.google.com/d/msgid/glorp-group/212f6892-ae48-479b-b411-b149494208d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
To view this discussion on the web visit https://groups.google.com/d/msgid/glorp-group/CAGWHZ993z7S_WhuFM4gE8YNFo6D5d8SikuKkBVTW-D99Guqekw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Eager loading by default possible ?

Jan van de Sandt
Yes, I found an example and now it works. 

The mappings looks like this:

mapping := (aDescriptor newMapping: ToManyMapping)
attributeName: #b;
referenceClass: B;
join: (Join
from: (table fieldNamed: 'ID')
to: (bTable fieldNamed: 'A_ID')).
mapping query alsoFetch: [ :each | each c ].

Thank you!

On Thursday, June 6, 2019 at 7:02:34 PM UTC+2, alan.knight wrote:
Yes, it's definitely possible. Look for sends of alsoFetch: inside descriptors in the tests.

On Thu, 6 Jun 2019 at 09:31, Jan van de Sandt <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="jIfIFS_eAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jvds...@...> wrote:
Hello list,

With a query you can use the alsoFetch:  method to "eager load" related objects. Is it possible to specify a mapping so that Glorp does this by default?

My Model is something like this:

Class A ----(*)--> Class B ----(1)--> Class C

Class A has a collection of B instances and each B instance refers to exactly one C instance. What I would like to have is that when Glorp loads the the collection of B instances for an A instance it also loads the C instances using a join query.

Cheers,
Jan.

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="jIfIFS_eAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">glorp...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="jIfIFS_eAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">glorp...@....
Visit this group at <a href="https://groups.google.com/group/glorp-group" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/glorp-group&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/glorp-group&#39;;return true;">https://groups.google.com/group/glorp-group.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/glorp-group/212f6892-ae48-479b-b411-b149494208d5%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/glorp-group/212f6892-ae48-479b-b411-b149494208d5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/glorp-group/212f6892-ae48-479b-b411-b149494208d5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/glorp-group/212f6892-ae48-479b-b411-b149494208d5%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
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 post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
To view this discussion on the web visit https://groups.google.com/d/msgid/glorp-group/03cc84f0-7baa-4037-9b16-edd439d77f92%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Eager loading by default possible ?

jtuchel
Jan,


please be very sure you ALWAYS want these dependent objects loaded. We've used this just to find out there are situations in our Application where this is not desired.. ;-)


I have a related question I have been wondering about for a while:

What is the exact difference between shouldProxy: false and alsoFetch:?


All I've found out so far is that shouldProxy doesn't work as expected, but I haven't found out what exactly to expect ;-)))

Joachim




Am Donnerstag, 6. Juni 2019 20:37:08 UTC+2 schrieb Jan van de Sandt:
Yes, I found an example and now it works. 

The mappings looks like this:

mapping := (aDescriptor newMapping: ToManyMapping)
attributeName: #b;
referenceClass: B;
join: (Join
from: (table fieldNamed: 'ID')
to: (bTable fieldNamed: 'A_ID')).
mapping query alsoFetch: [ :each | each c ].

Thank you!

On Thursday, June 6, 2019 at 7:02:34 PM UTC+2, alan.knight wrote:
Yes, it's definitely possible. Look for sends of alsoFetch: inside descriptors in the tests.

On Thu, 6 Jun 2019 at 09:31, Jan van de Sandt <[hidden email]> wrote:
Hello list,

With a query you can use the alsoFetch:  method to "eager load" related objects. Is it possible to specify a mapping so that Glorp does this by default?

My Model is something like this:

Class A ----(*)--> Class B ----(1)--> Class C

Class A has a collection of B instances and each B instance refers to exactly one C instance. What I would like to have is that when Glorp loads the the collection of B instances for an A instance it also loads the C instances using a join query.

Cheers,
Jan.

--
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 post to this group, send email to [hidden email].
Visit this group at <a href="https://groups.google.com/group/glorp-group" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/group/glorp-group&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/glorp-group&#39;;return true;">https://groups.google.com/group/glorp-group.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/glorp-group/212f6892-ae48-479b-b411-b149494208d5%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/glorp-group/212f6892-ae48-479b-b411-b149494208d5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/glorp-group/212f6892-ae48-479b-b411-b149494208d5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/glorp-group/212f6892-ae48-479b-b411-b149494208d5%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
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 post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
To view this discussion on the web visit https://groups.google.com/d/msgid/glorp-group/6a324a5a-5131-448f-ba80-722d51dfdb34%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Eager loading by default possible ?

Jan van de Sandt
Hi Joachim,

I also tried setting shouldProxy to false. But this results in 1 + N queries instead of a single query with a join. 

You are right that specifying alsoFetch in a mapping may result in loading too much data that you don't always need. Or the related data is already cached and the fetch is also not necessary. But in my concrete situation this is not the case.

Jan.



On Thu, Jun 13, 2019 at 9:17 PM jtuchel <[hidden email]> wrote:
Jan,


please be very sure you ALWAYS want these dependent objects loaded. We've used this just to find out there are situations in our Application where this is not desired.. ;-)


I have a related question I have been wondering about for a while:

What is the exact difference between shouldProxy: false and alsoFetch:?


All I've found out so far is that shouldProxy doesn't work as expected, but I haven't found out what exactly to expect ;-)))

Joachim




Am Donnerstag, 6. Juni 2019 20:37:08 UTC+2 schrieb Jan van de Sandt:
Yes, I found an example and now it works. 

The mappings looks like this:

mapping := (aDescriptor newMapping: ToManyMapping)
attributeName: #b;
referenceClass: B;
join: (Join
from: (table fieldNamed: 'ID')
to: (bTable fieldNamed: 'A_ID')).
mapping query alsoFetch: [ :each | each c ].

Thank you!

On Thursday, June 6, 2019 at 7:02:34 PM UTC+2, alan.knight wrote:
Yes, it's definitely possible. Look for sends of alsoFetch: inside descriptors in the tests.

On Thu, 6 Jun 2019 at 09:31, Jan van de Sandt <[hidden email]> wrote:
Hello list,

With a query you can use the alsoFetch:  method to "eager load" related objects. Is it possible to specify a mapping so that Glorp does this by default?

My Model is something like this:

Class A ----(*)--> Class B ----(1)--> Class C

Class A has a collection of B instances and each B instance refers to exactly one C instance. What I would like to have is that when Glorp loads the the collection of B instances for an A instance it also loads the C instances using a join query.

Cheers,
Jan.

--
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 post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
To view this discussion on the web visit https://groups.google.com/d/msgid/glorp-group/212f6892-ae48-479b-b411-b149494208d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
To view this discussion on the web visit https://groups.google.com/d/msgid/glorp-group/6a324a5a-5131-448f-ba80-722d51dfdb34%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
To view this discussion on the web visit https://groups.google.com/d/msgid/glorp-group/CAGZkxkA5dsOXxxdqNM9UFXNv7Pdt%2BYQB7vaiSx1mW4Vbr%3D62eA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.