Noup it's not the same thing. I understand what your talking about. Since you
can go from User to Person you should be able to do the inverse path.
I think that HasOne was designed to relate other objects by their ID Field.
Since you have PersonID that is a FK for Person, that's why you can go from
user to person but you don't have the opposite (Userid in Person table).
<object name="myFirstObject">
<hasOne name="mySecondObject">
<relate from="myFirstObjectForeignKeyField"
to="mySecondObjectPrimaryKeyField"/>
</hasOne>
</object>That's who it works. João Fernandes -----Original Message----- From: [EMAIL PROTECTED] on behalf of Cody Caughlan Sent: Wed 22-Feb-06 12:02 AM To: [email protected] Subject: RE: [Spam] RE: [Reactor For CF] [Spam] Mapping question Well, I understand this part now. However, in the XML I have explicitly defined the relationships so that basically Person.ID = User.PersonID, via: <object name="Person"> <hasOne name="User"> <relate from="ID" to="PersonID" /> </hasOne> </object> So this should work just fine: <cfset PersonRecord = Reactor.createRecord("Person")> <cfset PersonRecord.setID(3)> <cfset PersonRecord.load()> <cfset UserRecord = PersonRecord.getUserRecord()> <!--- get associated User record ---> <cfoutput>My Username is = #UserRecord.getUserName()#</cfoutput> Except that the UserRecord is empty. I am thinking that when I do a "PersonRecord.getUserRecord()", it internally does the .load() on PersonID because I have told it to in the above XML. Going the exact opposite direction via: <object name="User"> <hasOne name="Person"> <relate from="PersonID" to="ID" /> </hasOne> </object> And doing the CF just the opposite DOES work, as it does use exactly what you just said, the primary keys. This latter method is how the Customer/Address sample is setup in "Reactor Documentation.doc". I thought going backwards (my first approach) would be similar. /Cody -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of João Fernandes Sent: Tuesday, February 21, 2006 3:38 PM To: [email protected] Subject: RE: [Spam] RE: [Reactor For CF] [Spam] Mapping question Doug there is no need I think, The problem is that Cody is expecting that Load method checks every value of the Transfer object to see if any was set. Cody the load method works this way: If no fieldList is provided, it will try to load from the PK. If you do provide, it will execute all setters for the fieldList and then load the object using <cfset _getDao().read(_getTo(),fieldList)> since the fieldList in your case is not provided, it will try to read from the PK. resuming what will work: <cfset record = reactor.createRecord("SomeRecord")> <cfset record.setMyPkID(someval)> <cfset record.load()> <cfset record = reactor.createRecord("SomeRecord")> <cfset record.load(MyPkID=somePKval)> <cfset record = reactor.createRecord("SomeRecord")> <cfset record.load(SomeOtherColumn=someOtherval)> This won't work: <cfset record = reactor.createRecord("SomeRecord")> <cfset record.setSomeOtherColumn(someOtherval)> <cfset record.load()> João Fernandes -----Original Message----- From: [EMAIL PROTECTED] on behalf of Doug Hughes Sent: Tue 21-Feb-06 10:23 PM To: [email protected] Subject: RE: [Spam] RE: [Reactor For CF] [Spam] Mapping question Send me a zip with the following: 1) a backup of your database 2) a simple cfm that, when run, reproduces the problem each and every time 3) detailed, step by step instructions on what I need to do to reproduce the problem. Send that to [EMAIL PROTECTED] As soon as I have time (which may be a few days to a week or longer) I will run the test and see if I'm having the same issues. Based on that I should be able to fix the problem. I need this because reactor seems to work for me and I don't have the time (as much as I wish I did) to try a dozen things to fix the problem. Your time and help with this would be very valuable to me. Doug -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Chris Terrebonne Sent: Tuesday, February 21, 2006 2:26 PM To: [email protected] Subject: RE: [Spam] RE: [Reactor For CF] [Spam] Mapping question You're not alone with this issue. I ran into this a couple of weeks ago. There didn't appear to be much interest in it at that point so I just switched to specifying the relation directly in the load() method. Hopefully you will have more luck getting this corrected... Chris -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Cody Caughlan Sent: Tuesday, February 21, 2006 12:53 PM To: [email protected] Subject: RE: [Spam] RE: [Reactor For CF] [Spam] Mapping question I have traced the culprit down to the UserDao.read() in my project folder. Since my "arguments.fieldList" is blank, the <cfelse> kicks in and it looks like this: <cfset qRead = UserGateway.getByFields( ID = arguments.to.ID ) /> If I change this to: <cfset qRead = UserGateway.getByFields( PersonID = arguments.to.PersonID ) /> Then the query uses the appropriate value and it works. In looking at the hint for the UserRecord.load() method it says: "I load the User record. All of the Primary Key values must be provided for this to work" I think this might be the clue. In this case the column in my "User" table which links back to the "Person" table it not the primary key but a foreign key. I dont think this should make a difference since there is still a 1-to-1 relationship. How can I get the UserDao.read() to refer to the correct column? Isnt this the information that is in the XML in the first place? Thanks /Cody -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Cody Caughlan Sent: Tuesday, February 21, 2006 9:27 AM To: [email protected] Subject: RE: [Spam] RE: [Reactor For CF] [Spam] Mapping question My PersonRecord.getUserRecord() looks like this: <cffunction name="getUserRecord" access="public" output="false" returntype="reactor.project.Meridian_M1.Record.UserRecord"> <cfif NOT IsDefined("variables.UserRecord")> <cfset variables.UserRecord = _getReactorFactory().createRecord("User") /> <cfset variables.UserRecord.load() /> </cfif> <cfreturn variables.UserRecord /> </cffunction> Its doing a "load" w/o an ID, so of course its going to return an empty bean. And yes, you're right, the query should be doing a lookup on the User.PersonID column and not User.ID. I am not really sure where to trouble-shoot this. /cody -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Doug Hughes Sent: Monday, February 20, 2006 6:12 PM To: [email protected] Subject: RE: [Spam] RE: [Reactor For CF] [Spam] Mapping question So, you've got this query that's the issue: SELECT [User].[ID] AS [ID] , [User].[PersonID] AS [PersonID] , [User].[UserName] AS [UserName] , [User].[Password] AS [Password] , [User].[ChangePassOnLogin] AS [ChangePassOnLogin] FROM [Meridian].[dbo].[User] AS [User] WHERE [User].[ID] = ? According to the output, your parameter is set to 0 "Query Parameter Value(s) - Parameter #1(cf_sql_integer) = 0" I'm wondering if you loaded your person. (It would appear so, the person.id parameter is set to 3.) Assuming your second query is a result of calling person.getUserRecord(), That second query should look like this: SELECT [User].[ID] AS [ID] , [User].[PersonID] AS [PersonID] , [User].[UserName] AS [UserName] , [User].[Password] AS [Password] , [User].[ChangePassOnLogin] AS [ChangePassOnLogin] FROM [Meridian].[dbo].[User] AS [User] WHERE [User].[PersonID] = ? What's the code in your project PersonRecord's getUserRecord() method look like? Doug -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Cody Caughlan Sent: Monday, February 20, 2006 9:04 PM To: [email protected] Subject: [Spam] RE: [Reactor For CF] [Spam] Mapping question No, in our case a there is only a 1-to-1 mapping between Person / Users. Now, this isnt a normalized design and I re-did my DB/reactor.xml to use a "UserPersonLink" table and I got this to work in Reactor (but it kind of sucks to have to use a "getUserPersonLinkIterator.getQuery()" when you know you are only getting one row from this link table and then shove this "UserID" off to the UserRecord.setID() method.... I wanted to get my original design going because it seems so simple and its better to start small, right? Anyways, I referred back to my original reactor.xml and put the cfabort in the abstractGateway.cfc method, this is what it returns: SELECT [Person].[ID] AS [ID] , [Person].[FirstName] AS [FirstName] , [Person].[MiddleInit] AS [MiddleInit] , [Person].[LastName] AS [LastName] , [Person].[BirthDate] AS [BirthDate] , [Person].[Gender] AS [Gender] , [Person].[CreationDate] AS [CreationDate] , [Person].[Approved] AS [Approved] , [Person].[Active] AS [Active] FROM [appName].[dbo].[Person] AS [Person] WHERE [Person].[ID] = ? so it doesnt really return anything useful because it bombs out on the first gateway lookup and not the second one that we want (the lookup into the User table)...attached is my debugging output for all the queries ran.. Thanks alot! /Cody -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Doug Hughes Sent: Monday, February 20, 2006 5:47 PM To: [email protected] Subject: [Spam] RE: [Reactor For CF] [Spam] Mapping question Now, first off, wouldn't a person have many Users? And a User would haveOne Person? I'd try this: <object name="Person"> <hasMany name="User"> <relate from="ID" to="PersonID" /> </hasMany > </object> But honestly, this shouldn't make a difference. There must be something simple that's going wrong here. Like the personID is really in the person table? It maybe it's crossing the two generic "ID" columns. Any chance you can do this: Go into the abstractGateway.cfc and throw a cfabort right before the </cfquery> this should cause the query to be output. I'd love to know if there's anything weird about this. Doug -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Cody Caughlan Sent: Monday, February 20, 2006 8:20 PM To: [email protected] Subject: [Spam] [Reactor For CF] [Spam] Mapping question Hello, This is concerning MSSQL. I have 2 tables, "Person" and "User". Person ------ ID (int, primary key, identity) FirstName, etc... User ---- ID (int, primary key, identity) PersonID (foreign key back to Person table) UserName, etc... My reactor.xml looks like this: <object name="Person"> <hasOne name="User"> <relate from="ID" to="PersonID" /> </hasOne> </object> This *doesnt* work, for some unknown reason. When I add a non-primary key field to my Person table (I tried "UserID") and I manually populate it with the appropriate primary key ID from the "Users" table and switch my reactor.xml to: <relate from="UserID" to="ID" /> it *does* work. Its almost as if, if I use a non-primary key in the "object" XML declaration it will work, but if I specify its identity column it will not work. When I say it "does not" work, I mean that that when I call the PersonRecord.getUserRecord() method, the returned UserRecord is always empty and doesnt contain the appropriate data. Yes, I made sure the keys are correct (correct values in the DB). Note, that I *can* read the correct data from the PersonRecord, it just breaks down when trying to read the relevant UserRecord. I am sure I am doing something stupid but I have been looking at this for quite some time to no availl. Thanks /Cody -- 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/ -- 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/
<<winmail.dat>>

