Hi there, I wonder if it is possible to map a list of classes in a way so that an abstract superclass which has each subclass reside in its own table has a tree of subclasses that share one table. Or, to put it differently: I want to use a FilteredTyeResolver for a few subclasses in a tree of clases that are mapped using a HorizontalTypeResolver. Example: There is a Class named Incident. It has 5 subclasses, each residing in their own table. One of these subclasses has a few subclasses, let's call the superclass a TimedIncident, which all share the same attributes and therefor would be stored in one table. If it is possible to map these classes, I have a bonus question: How can I define a OneToManyMapping from, say, Customer, to TimedIncident (or better its subclasses)? The customer_id resides in the timed_incident table. Hope my explanation is good enough... 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/f20c437a-f4bf-4f19-be79-7d5bda59f032n%40googlegroups.com. |
Hi Joachim,
It's an interesting question. As far as I understand you can't nest type resolvers that way, since it's not an arbitrary depth "composite" structure, but instead, there is a 1:1 relation between the TypeResolver and the TypeMapping. So if you have this hierarchy: Incident (root horizontal resolver) - TimedIncident - - RelativelyTimedIncident - - AbsolutelyTimedIncident - CriticalIncident - SelfInflictedIncident - ... You can't query Incident and get the instances of all the subclasses. I wonder what it would take to make that work, because resolvers are mostly about knowing the tables involved. BONUS: > How can I define a OneToManyMapping from, say, Customer, to TimedIncident (or better its subclasses)? > The customer_id resides in the timed_incident table. Without all the above limitations it would be just about doing this: (aDescriptor newMapping: ToManyMapping) attributeName: #incidents; referenceClass: TimedIncident; join: (Join from: (table fieldNamed: 'id') to: ((self tableNamed: 'timed_incident') fieldNamed: 'customer_id')) Hopefully I got it wrong and that's possible, it would be something good to learn. :-) Regards! Esteban A. Maringolo On Fri, Mar 26, 2021 at 9:14 AM jtuchel <[hidden email]> wrote: > > > Hi there, > > I wonder if it is possible to map a list of classes in a way so that an abstract superclass which has each subclass reside in its own table has a tree of subclasses that share one table. > Or, to put it differently: I want to use a FilteredTyeResolver for a few subclasses in a tree of clases that are mapped using a HorizontalTypeResolver. > > Example: > There is a Class named Incident. It has 5 subclasses, each residing in their own table. One of these subclasses has a few subclasses, let's call the superclass a TimedIncident, which all share the same attributes and therefor would be stored in one table. > > If it is possible to map these classes, I have a bonus question: > > How can I define a OneToManyMapping from, say, Customer, to TimedIncident (or better its subclasses)? The customer_id resides in the timed_incident table. > > > Hope my explanation is good enough... > > 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/f20c437a-f4bf-4f19-be79-7d5bda59f032n%40googlegroups.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/CAJMgPCKustkxgA8jWxv50DXgwLJHydpK8jgFr-rx6o_O2NDwiw%40mail.gmail.com. |
Esteban,
Am 26.03.21 um 13:37 schrieb Esteban Maringolo: > Hi Joachim, > > It's an interesting question. I know ;-) > As far as I understand you can't nest type resolvers that way, since > it's not an arbitrary depth "composite" structure, but instead, there > is a 1:1 relation between the TypeResolver and the TypeMapping. Ouch. > So if you have this hierarchy: > > Incident (root horizontal resolver) > - TimedIncident > - - RelativelyTimedIncident > - - AbsolutelyTimedIncident > - CriticalIncident > - SelfInflictedIncident > - ... Yes, that's what it looks like. And some classes only reference TimedIncidents and no others. > You can't query Incident and get the instances of all the subclasses. In this specific case, this wouldn't be necessary, that variable only holds TimedIncidents. But of course the ability to get all Incidents is still needed for other purposes... > I wonder what it would take to make that work, because resolvers are > mostly about knowing the tables involved. So far, I always failed in such experiments with Glorp... > > BONUS: >> How can I define a OneToManyMapping from, say, Customer, to TimedIncident (or better its subclasses)? >> The customer_id resides in the timed_incident table. > Without all the above limitations it would be just about doing this: > > (aDescriptor newMapping: ToManyMapping) > attributeName: #incidents; > referenceClass: TimedIncident; > join: > (Join > from: (table fieldNamed: 'id') > to: ((self tableNamed: 'timed_incident') fieldNamed: 'customer_id')) Well, it's a Bonus question, so of course the limitations above apply ;-) Thanks for answering, Joachim -- ----------------------------------------------------------------------- Objektfabrik Joachim Tuchel mailto:[hidden email] Fliederweg 1 http://www.objektfabrik.de D-71640 Ludwigsburg http://joachimtuchel.wordpress.com Telefon: +49 7141 56 10 86 0 Fax: +49 7141 56 10 86 1 -- 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/bb3017f8-2fe3-7233-1aea-51036d6846de%40objektfabrik.de. |
So given that I cannot mix or nest the TypeResolvers, I am trying with
individuel tables for the TimedIncidents. It seems impossibly, however, to formulate an ToManyMapping with a polymorphic Join (VariableJoin). Something like this: Customer>>incidents refences a list of TimedIncidents (meaning instances of one of the subclasses of TimedIncident) which can be stored in either the Timd_inc_relative or Timed_inc_Abs table.... So far I could only successfully use VariableJoins for OneToOneMappings for tables in which the foreign key is stored. So each TimedIncident stores the customer_id and when you ask a Customer for its incidents, it will request both "subtables" for candidates to add to the result collection... Ideas? Am 26.03.21 um 15:34 schrieb [hidden email]: > Esteban, > > > > > Am 26.03.21 um 13:37 schrieb Esteban Maringolo: >> Hi Joachim, >> >> It's an interesting question. > > I know ;-) > > >> As far as I understand you can't nest type resolvers that way, since >> it's not an arbitrary depth "composite" structure, but instead, there >> is a 1:1 relation between the TypeResolver and the TypeMapping. > > Ouch. > > >> So if you have this hierarchy: >> >> Incident (root horizontal resolver) >> - TimedIncident >> - - RelativelyTimedIncident >> - - AbsolutelyTimedIncident >> - CriticalIncident >> - SelfInflictedIncident >> - ... > > Yes, that's what it looks like. And some classes only reference > TimedIncidents and no others. > >> You can't query Incident and get the instances of all the subclasses. > > In this specific case, this wouldn't be necessary, that variable only > holds TimedIncidents. But of course the ability to get all Incidents > is still needed for other purposes... > > >> I wonder what it would take to make that work, because resolvers are >> mostly about knowing the tables involved. > > So far, I always failed in such experiments with Glorp... > > >> >> BONUS: >>> How can I define a OneToManyMapping from, say, Customer, to >>> TimedIncident (or better its subclasses)? >>> The customer_id resides in the timed_incident table. >> Without all the above limitations it would be just about doing this: >> >> (aDescriptor newMapping: ToManyMapping) >> attributeName: #incidents; >> referenceClass: TimedIncident; >> join: >> (Join >> from: (table fieldNamed: 'id') >> to: ((self tableNamed: 'timed_incident') fieldNamed: >> 'customer_id')) > > Well, it's a Bonus question, so of course the limitations above apply ;-) > > Thanks for answering, > > > Joachim > > > -- ----------------------------------------------------------------------- Objektfabrik Joachim Tuchel mailto:[hidden email] Fliederweg 1 http://www.objektfabrik.de D-71640 Ludwigsburg http://joachimtuchel.wordpress.com Telefon: +49 7141 56 10 86 0 Fax: +49 7141 56 10 86 1 -- 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/0265f48d-95b7-494f-068e-d232f71553b9%40objektfabrik.de. |
Free forum by Nabble | Edit this page |