Good morning/evening all,

My first post so be gentle.  Loving reactor and am integrating it into
my first app.

THE SITUATION...

I have a Job Table and a User Table.

Their are 2 relationships between the Job and the User
- a job has an owner
- a job has a manager

These are defined by 2 foreign keys in job:
- ownerID
- managerID


THE CURRENT CONFIG....


       <object name="Job">

               <!-- This section defines the relationship for the Jobs Owner -->
               <hasOne name="User">
                       <relate from="ownerID" to="objectID" />
               </hasOne>

               <!-- This section defines the relationship for the Jobs
Manager -->
               <hasOne name="User">
                       <relate from="managerID" to="objectID" />
               </hasOne>
       </object>

       <object name="User">
               <hasMany name="Job">
                       <relate from="objectID" to="ownerID" />
               </hasOne>
               <hasMany name="Job">
                       <relate from="objectID" to="managerID" />
               </hasOne>
       </object>


THE REQUEST...

How can I define which relationship I am refering to using the getUserRecord()?


THE SUGGESTION....

I guess the obvious solution would be to provide an Alias on each of
the relationships defined in the xml and then call using something
like:

      JobRecord.getUserRecord('Owner') or JobRecord.getUserRecord('Manager')
      UserRecord.getJobIterator('Owned') or UserRecord.getJobIterator('Managed')


       <object name="Job">
               <hasOne name="User" alias='Owner'>
                       <relate from="ownerID" to="objectID" />
               </hasOne>
               <hasOne name="User" alias='Manager'>
                       <relate from="managerID" to="objectID" />
               </hasOne>
       </object>

       <object name="User">
               <hasMany name="Job" alias='Owned'>
                       <relate from="objectID" to="ownerID" />
               </hasOne>
               <hasMany name="Job" alias='Managed'>
                       <relate from="objectID" to="managerID" />
               </hasOne>
       </object>



REQUEST...

Yes I could restructure and have a 1:many relationship and a flag in
the bridging table that defines whether the relationship is a Manager
or Owner but that is a seperate discussion. Please don't offer as a
solution ;)


FURTHER THOUGHT... ;)

I also have another 1:many relationship from Job to User called
"Developers". But this can wait till the first issue is solved.




-- Matthew Bryant



-- Reactor for ColdFusion Mailing List -- [email protected]
-- Archives at http://www.mail-archive.com/reactor%40doughughes.net/


Reply via email to