Oops, sorry about that! Accidentally sent before writing part 2, so here it
is:

So now that you know my table schema, here's the excerpt of Reactor.xml:

 <object name="tblUser">
    <hasMany name="tblRole">
          <link name="tblUserRole" />
      </hasMany>
  </object>

  <object name="tblRole">
      <hasMany name="tblUser">
          <link name="tblUserRole" />
      </hasMany>
  </object>

  <object name="tblUserRole">
      <hasOne name="tblUser">
          <relate from="intUserItemID" to="intItemID" />
      </hasOne>
      <hasOne name="tblRole">
          <relate from="intRoleID" to="intRoleID" />
      </hasOne>
  </object>

For some reason, this isn't working at all to generate anything. In my
RoleService.cfc, I pass a TblUser object to my method getUserRolesByUser()
like so:

<cffunction name="init" access="public" returntype="RoleService"
output="false">
       <cfargument name="ormService" type="any" required="true"
hint="Dependency ormService" />

       <!--- assign arguments to variables scope --->
       <cfset variables.ormService = arguments.ormService />

       <!--- set into variables scope anything you need from the ormService
--->
       <cfset variables.RoleGateway =
variables.ormService.createGateway("tblRole")
/>
       <cfset variables.UserRoleGateway =
variables.ormService.createGateway("tblUserRole")
/>

       <cfreturn this />
    </cffunction>

<cffunction name="getUserRolesByUser" access="public" returntype="any"
output="false" hint="Given user object, returns list of roles for that
user.">
        <cfargument name="objUser" type="any" required="true" />

        <cfscript>
            var l = StructNew();
        </cfscript>

        <cfset l.qryRoles = arguments.objUser.getTblRoleIterator().getQuery()
/>
        <cfset l.lstUserRoles = l.qryRoles.nvcRoleTitle />

        <cfreturn l.lstUserRoles />
    </cffunction>

This failed, so I tried dumping my arguments.objUser and aborting mid-method
to see what it looked like. There is no getTblRoleIterator() method, or any
iterator method for that matter, anywhere on it. What gives? What did I
miss? Please help! Obviously it wasn't auto-generated yet, which sort of
brings me to my next questions..

Although I read the Reactor docs fully, I can't seem to get a firm sense of
what actually reloads the framework (the reactor.xml file). Also, when is
the point of auto-generation of methods like getTblRoleIterator, when I told
my Reactor object (ormservice here, from ColdSpring) to
createGateway("TblRole")?

Your help is much appreciated, because if don't sort this out soon I'll have
to fall back on manually creating queries that Reactor should be able to do
for me if only I knew how to do this properly.

Cheers,
Dave

On 01/12/2007, Dave Knapik <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> This is my first foray into the world of Reactor. I've been using it for
> about a month, and all has mostly been well, but I've come to the point
> where I need to implement a basic link table relationship like so (first the
> SQL 2000 table schema descriptions and then the reactor.xml excerpts):
>
> tblUser
> ____
> intItemID
> nvcFirstName
> nvcLastName
> ... more fields...
>
>
> tblRole
> ------
> intRoleID
> nvcRoleTitle
> nvcRoleDescription
> ... more fields ...
>
>
> tblUserRole
> ------
> intUserRoleID (my PK for the link table)
> intUserItemID (my FK back to tblUser.intItemID)
> intRoleID (my FK back to tblRole.intRoleID)
>
> There is a fourth table, tblItems, which accounts for the ropey naming
> conventions here, and it's just something my company uses that I can't get
> around (essentially a User is an Item, as are a lot of things, so
> tblUser.intItemID FK's back to tblItems.intItemID rather than having an
> auto-incrementing PK of its own).
>
>
>


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

Reply via email to