Sorry ray, you missunderstood me,

This is what reactor does when you call load method on your record.

 <cfset record.load()>

Executes load method from the abstractRecord (reactor.base.abstractRecord)

Look this code
<!-------------- CODE INSIDE LOAD METHOD OF THE RECORD -------------------->
<cfif IsDefined("arguments") AND fieldList IS 1>
        <cfset fieldList = arguments[1] />

        <cfelseif IsDefined("arguments") AND fieldList IS NOT 1>
                <cfloop collection="#arguments#" item="item">
                        <cfinvoke component="#this#" method="set#item#">
                                <cfinvokeargument name="#item#"
value="#arguments[item]#" />
                                </cfinvoke>
                        </cfloop>

                </cfif>

                <cftry>
                        <cfset _getDao().read(_getTo(), fieldList) />
                        <cfcatch type="Reactor.Record.NoMatchingRecord">
                                <cfset nothingLoaded = true />
                        </cfcatch>
                </cftry>
<!-------------- CODE INSIDE LOAD METHOD OF THE RECORD -------------------->

When it calls <cfset _getDao().read(_getTo(), fieldList) />
It will invoke read method in the DAO passing all arguments to it, but since
you didn't pass any (in this case) inside the DAO you'll be executing 

<!-------------- CODE INSIDE READ METHOD OF THE DAO ----------------------->
<cfif Len(arguments.loadFieldList)>
                        <cfset UserQuery = UserGateway.createQuery() />
                        <cfloop list="#arguments.loadFieldList#"
index="field">
                                <cfset UserQuery.getWhere().isEqual("User",
field, arguments.to[field]) />
                        </cfloop>

                        <cfset qRead =
UserGateway.getByQuery(UserQuery,true) />
                <cfelse>
                        <cfset qRead = UserGateway.getByFields(

                        ) />
                </cfif>
<!-------------- CODE INSIDE READ METHOD OF THE DAO ----------------------->
Since the arguments.loadFieldList in your case will be empty, it will
execute 
<cfset qRead = UserGateway.getByFields( ) /> 

It should be 
<cfset qRead = UserGateway.getByFields( UserId = arguments.to.UserId ) />

Why is it doing this?

Because it couldn't find the primary key during the generation

Try to run this query 

SELECT 
                                col.COLUMN_NAME as name,
                                CASE
                                        WHEN colCon.CONSTRAINT_NAME IS NOT
NULL THEN 'true'
                                        ELSE 'false'
                                END as primaryKey,
                                CASE
                                        WHEN
columnProperty(object_id(col.TABLE_NAME), col.COLUMN_NAME, 'IsIdentity') > 0
THEN 'true'
                                        ELSE 'false'
                                END AS [identity],
                                CASE
                                        WHEN col.IS_NULLABLE = 'No' THEN
'false'
                                        ELSE 'true'
                                END as nullable,

                                col.DATA_TYPE as dbDataType,
                                CASE
                                        WHEN
ISNUMERIC(col.CHARACTER_MAXIMUM_LENGTH) = 1 THEN
col.CHARACTER_MAXIMUM_LENGTH
                                        ELSE 0
                                END as length,
                                col.COLUMN_DEFAULT as [default]
                        FROM INFORMATION_SCHEMA.COLUMNS as col LEFT JOIN
INFORMATION_SCHEMA.TABLE_CONSTRAINTS as tabCon
                                ON col.TABLE_NAME = tabCon.TABLE_NAME
                                AND tabCon.CONSTRAINT_TYPE = 'PRIMARY KEY'
                        LEFT JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE
as colCon
                                ON col.COLUMN_NAME = colCon.COLUMN_NAME
                                AND col.TABLE_NAME = colCon.TABLE_NAME
                                AND colCon.CONSTRAINT_NAME =
tabCon.CONSTRAINT_NAME
                        WHERE col.TABLE_NAME = 'User'

And drop the result here.

João Fernandes








-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Ray West
Sent: quinta-feira, 10 de Agosto de 2006 16:41
To: [email protected]
Subject: Re: [Reactor for CF] Ambiguous Record Problem

OK, replying to a couple of emails here. Thanks everyone for the help...

Yes the UserID field is definitely a PK. I turned it off and saved and 
turned it back on to be sure it was set. Same problem exists.

While the PK was turned off I tried the shortcut method. It still worked.

I am in development mode.

I have deleted all of my project files and they were recreated... Same 
problem exists.

So are you saying that I can only 'search' by fields that are primary 
keys? What if I want to create a record and run a login script on it 
comparing a username and password that are not keys? This works using 
the shortcut method. Why should it not work by setting the properties 
and loading the object?

Hope I answered everything.

Ray


João Fernandes wrote:
> The problem is, when you use 
> <cfset record.setUserid(someval)>
> <cfset record.load()>
> 
> In the read method inside UserDao.cfc if you take a look into the code I
> posted in my last email, load() and load(userid=val) go through different
> paths. The load() method goes through 
> 
> <cfset qRead = UserGateway.getByFields(
>                               <!------- This part is blank ------->
>                       ) /> 
> 
> The part in blank is where reactor should put the code to load the record
> based on the primary key definition. Delete your project files and
> regenerate to see if the problem persists.
> 
> João Fernandes
> 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
> Behalf Of Ray West
> Sent: quinta-feira, 10 de Agosto de 2006 16:15
> To: [email protected]
> Subject: Re: [Reactor for CF] Ambiguous Record Problem
> 
> The shortcut method appears to be using the same setUserID property 
> setter that I am calling. And yet the shortcut method works...
> 
> Ray
> 
> 
> Ray West wrote:
>> frak... well... it is not working here and I need to be able to pass the 
>> object into a method for processing (not to mention that that is the 
>> better way to do it) so the shortcut method won't work for this.
>>
>> R
>>
>> Jared Rypka-Hauer wrote:
>>> I've been using it just fine with SQL Server for eons... well, not 
>>> eons, but a long time.
>>>
>>> I'm trying to think of what the issue could be man. Coming up, as 
>>> usual, with a big fat blank. ;)
>>>
>>> J
>>>
>>>
>>> ------------------------------------------------
>>>
>>> Jared C. Rypka-Hauer
>>>
>>> Continuum Media Group LLC
>>>
>>> http://www.web-relevant.com
>>>
>>> Member, Team Macromedia - ColdFusion
>>>
>>>
>>> "That which does not kill me makes me stranger." - Yonah Schmeidler
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Aug 10, 2006, at 9:25 AM, Ray West wrote:
>>>
>>>> NP Chris,
>>>>
>>>> This is an exception thrown by Reactor and not a CF error. I don't 
>>>> get anything extra when I turn on debugging in CF. A query of some 
>>>> sort apparently runs fine, it just returns unexpected data.
>>>>
>>>> I am going to load the new version and see if there is any difference.
>>>>
>>>> Have anyone reproduced this or gotten it to run correctly with SQL 
>>>> Server?
>>>>
>>>> Ray
>>>>
>>>> Chris Phillips wrote:
>>>>> I appologize Ray.
>>>>> I didn't catch that you were saying that
>>>>> <cfset objUser.setUserID(1) />
>>>>> <cfset objUser.load() />
>>>>> didn't work
>>>>> and
>>>>> <cfset objUser.load(UserID=1) />
>>>>> did.
>>>>> Which makes this rather wierd.
>>>>> If it were me, I'd turn on debugging and watch the queries that CF 
>>>>> is generating to see how they are different.
>>>>> Let us know what you see.
>>>>> Regards,
>>>>> Chris
>>>>> On 8/9/06, *Ray West* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> 
>>>>> wrote:
>>>>>     It is... second guess? :-)
>>>>>     Can anyone repro this?
>>>>>     Ray
>>>>>     Chris Phillips wrote:
>>>>>      > First guess is that UserID is not a PrimaryKey.
>>>>>      >
>>>>>      > On 8/9/06, *Ray West* < [EMAIL PROTECTED] <mailto:[EMAIL 
>>>>> PROTECTED]>
>>>>>     <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>> wrote:
>>>>>      >
>>>>>      >     Hi,
>>>>>      >
>>>>>      >     In MS SQL Server, whenever I create a record and do this:
>>>>>      >
>>>>>      >     <cfset objUser.setUserID (1) />
>>>>>      >     <cfset objUser.load() />
>>>>>      >
>>>>>      >     I get an ambiguous record error, even though there is 
>>>>> only one
>>>>>      >     record in
>>>>>      >     the table with that ID.
>>>>>      >
>>>>>      >     When I do:
>>>>>      >
>>>>>      >     <cfset objUser.load(UserID=1) />
>>>>>      >
>>>>>      >     It works fine.
>>>>>      >
>>>>>      >     Any help appreciated...
>>>>>      >
>>>>>      >     Ray
>>>>>      >
>>>>>      >
>>>>>      >
>>>>>      >
>>>>>      >     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>>>>>     -- --
>>>>>      >     -- -- -- -- --
>>>>>      >     Reactor for ColdFusion Mailing List
>>>>>      >     [email protected] <mailto:[email protected]>
>>>>>     <mailto:[email protected] <mailto:[email protected]>>
>>>>>      >     Archives at:
>>>>>     http://www.mail-archive.com/reactor%40doughughes.net/
>>>>>      >     < http://www.mail-archive.com/reactor%40doughughes.net/>
>>>>>      >     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
>>>>> -- -- --
>>>>>      >     -- -- -- -- --
>>>>>      >
>>>>>      >
>>>>>      >
>>>>>      >
>>>>>      > --
>>>>>      > Chris Phillips
>>>>>      > www.dealerpeak.com <http://www.dealerpeak.com>
>>>>>     <http://www.dealerpeak.com>
>>>>>      > Senior Application Developer
>>>>>      > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
>>>>> -- -- --
>>>>>      > -- -- -- --
>>>>>      > Reactor for ColdFusion Mailing List
>>>>>      > [email protected] <mailto:[email protected]>
>>>>>      > Archives at: 
>>>>> http://www.mail-archive.com/reactor%40doughughes.net/
>>>>>      > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
>>>>> -- -- --
>>>>>      > -- -- -- --
>>>>>     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
>>>>> -- --
>>>>>     -- -- -- --
>>>>>     Reactor for ColdFusion Mailing List
>>>>>     [email protected] <mailto:[email protected]>
>>>>>     Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
>>>>>     <http://www.mail-archive.com/reactor%40doughughes.net/>
>>>>>     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
>>>>> -- --
>>>>>     -- -- -- --
>>>>> -- 
>>>>> Chris Phillips
>>>>> www.dealerpeak.com <http://www.dealerpeak.com>
>>>>> Senior Application Developer
>>>>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
>>>>> -- -- -- --
>>>>> Reactor for ColdFusion Mailing List
>>>>> [email protected] <mailto:[email protected]>
>>>>> Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
>>>>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
>>>>> -- -- -- --
>>>>
>>>>
>>>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
>>>> -- -- -- --
>>>> Reactor for ColdFusion Mailing List
>>>> [email protected] <mailto:[email protected]>
>>>> Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
>>>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
>>>> -- -- -- --
>>>>
>>>
>>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
>>> -- -- -- --
>>> Reactor for ColdFusion Mailing List
>>> [email protected]
>>> Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
>>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
>>> -- -- -- --
>>
>>
>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
>> -- -- --
>> Reactor for ColdFusion Mailing List
>> [email protected]
>> Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
>> -- -- --
>>
>>
>>
> 
> 
> 
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> -- --
> Reactor for ColdFusion Mailing List
> [email protected]
> Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> -- --
> 
> 
> 
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
> Reactor for ColdFusion Mailing List
> [email protected]
> Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
> 
> 
> 



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



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

Reply via email to