Hi,
i'm new with GLORP (and smalltalk), i'm having a problem to build a "RelationshipMapping" between my tables, perhaps you could help me. I have the following DB structure: EVENT -> [event_id,..] PARTICIPANT -> [participant_id, event_id,...] PARTICIPANT_OPTION_LINK -> [id_option, id_participant] OPTION -> [option_id,option_value(text)] I need to be able of fetch the PARTICIPANT options FROM the Participant Object. i'm trying to do something like the code below in my descriptor, and i'm getting the following exception: (Unhandled exception: Joins should go from the table(s) associated with this descriptor to the other table(s)). do you have any suggestion of how could i do this relationship works ? Thank you, Armando Perico (aDescriptor newMapping: Glorp.RelationshipMapping) attributeName: #options; referenceClass: Option; usesLinkTable: true; mappingCriteria: (Glorp.Join from: ((self tableNamed: 'PARTICIPANT') fieldNamed: 'ID') to: ((self tableNamed: 'PARTICIPANT_OPTION_LINK') fieldNamed: 'ID_PARTICIPANT')); targetTableJoin: (Glorp.Join from: ((self tableNamed: 'PARTICIPANT_OPTION_LINK') fieldNamed: 'ID_OPTION') to: ((self tableNamed: 'OPTION') fieldNamed: 'ID')); _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
The message is being pretty precise in telling you what's
wrong. That join isn't going from and to the places that Glorp expects it
to. But the reason is that #targetTableJoin: is not what you are thinking
it is. See the method comment. "This is *NOT* supposed to be a
join from the link table to the target table. That's reverseJoin, and is
calculated automatically."
But basically, if you have foreign key constraints defined for your link table, the answer is to delete everything after "usesLinkTable: true" and just let Glorp figure out the join automatically. If the join is ambiguous, you can just specify the join from the source table to the link table. The rest can normally be computed automatically. And in most cases, all of it can be computed automatically. At 02:48 PM 2010-03-31, Armando Perico wrote: Hi, --
Alan Knight [|], Engineering Manager, Cincom Smalltalk
_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Free forum by Nabble | Edit this page |