Hello Guys,
I've been working with OO for some time now but there are still a few little things that escape me, so I'm looking for a definitive answer. When dealing with data access objects how should I be moving the data retrieved by them into the actually bean style object? As I see it at the moment I have two real options, the first is to have my function to return the query results, like this: <!--- Read ---> <cffunction name="read" access="public" output="false" returntype="query" hint="I read a record from persistence"> <cfargument name="CredentialID" required="true" type="numeric" hint="I'm the ID for the credential record to be read" /> <!--- Create Temporary Local Structure ---> <cfset var LOCAL = structNew() /> <!--- Query To Create Record ---> <cfquery name="LOCAL.Result" datasource=""> ... </cfquery> <cfreturn LOCAL.Result /> </cffunction> This involves me revoking the function, passing the ID of the record in as an argument and then dealing with the returned query results from wherever I revoke the object and put them into my bean. Or, I could inject the bean object into the DAO as a constructor, and then set directly from my method, something like this: <!--- Read ---> <cffunction name="read" access="public" output="false" returntype="void" hint="I read a record from persistence"> <!--- Create Temporary Local Structure ---> <cfset var LOCAL = structNew() /> <!--- Query To Create Record ---> <cfquery name="LOCAL.Result" datasource=""> ... WHERE Credential_ID = <cfqueryparam value="#VARIABLES.Instance.Bean.getID()#" /> </cfquery> <!--- Set Into Bean ---> <cfset VARIABLES.Instance.Bean.setUsername(LOCAL.Results.Username) /> <cfset VARIABLES.Instance.Bean.setPassword(LOCAL.Results.Password) /> <cfreturn /> </cffunction> Which of those is the best method for me to use? How do you guys deal with it? Or is there a different method all together that I've not read about? I look forward to hearing from you guys, Thanks a lot for all your help Rob ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| ColdFusion MX7 and Flex 2 Build sales & marketing dashboard RIAâs for your business. Upgrade now http://www.adobe.com/products/coldfusion/flex2?sdid=RVJT Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:281535 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4