I have an Address object. I also have a Company object as well as a User
object. Both Companies and Users can have addresses. Users may have the
same address as their company. Each Company can have several Users.
In the "old days" of SQL, I would establish a join table between Company
(with a FK) and Address (PK only). And a separate join table for User and
Address. For the sake of simplicity, I'll just ask about the Company >
Address relationship.
I'm having a hard time wrapping my head around the M2M relationship and how
a join table fits into an ORM. Logically, I'd like to ask the Company for
its address. So, it seems that I'll need to create a method in my
CompanyDecorator to ask the "CompanyAddresses" join object to retrieve its
addresses? Then create new "Addresses" property on the Company object
holding the resulting array of Address objects?
Or... is it possible (this is when my head turns to mush) for me to create a
o2m relationship on the Company linking to the join table? Then perhaps I
could continue to ask down the chain of objects for the Address? Something
like...
|----------get class---------------|-----ask o2m-----|------------ask
m2m----------|---ask for Address objects---|
Transfer.get("my.Class",45).getAddresses().getCompanyAddresses().getAddressArray()
I realize that the last bit of code isn't going to work... (read above about
"mush"), but it seems there might be a way for me to drill down using the
supplied o2m/m2m methods. Is this true? Or perhaps you can't have an o2m
and m2m using the same FK? I think read that somewhere.... So... I
wouldn't mind having 2 columns with the same data in them (same FKs).
--
Jason Durham
--
Jason Durham
--~--~---------~--~----~------------~-------~--~----~
Before posting questions to the group please read:
http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer
You received this message because you are subscribed to the Google Groups
"transfer-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/transfer-dev?hl=en
-~----------~----~----~----~------~----~------~--~---