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. |
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:
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. |
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:
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. |
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:
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. |
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:
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. |
Free forum by Nabble | Edit this page |