Well, i found that having a separate DAO for the subobject made things a lot
simplier. Going back to a previous thread, i got rid of a lot of stuff that
looked like this (in the query, but also in the form and the post submit
process):
<cfloop ... >
CFQUERY>
INSERT INTO mytable
(course,
degree,
emp_course_id...)
VALUES
(<cfqueryparam cfsqltype="cf_sql_varchar" value="#form["course"&i]#">,
<cfqueryparam cfsqltype="cf_sql_varchar" value="#form["degree"&i]#">,
<cfqueryparam cfsqltype="cf_sql_varchar" value="#form["emp_course_id"&i]#">)
</CFQUERY>
</cfloop>
And replaced it with something that looked like this:
<cfloop ... >
<cfset create() />
<cfloop query="variables.allFloors">
<cfset
createObject('component','com.HotelsOfTheWorld.dao.FloorDAO').init(
variables.Floor[number]).create() />
</cfloop>
The advantage to me was that it fully encapsulated multiple instances of the
subobject - and rather than making it more complicated, it made it a lot
simplier.
<shrug>
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of Sean Corfield
Sent: Wednesday, April 27, 2005 9:31 PM
To: [email protected]
Subject: Re: [CFCDev] While we're on the subject of DAOs
On 4/27/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> The answer I received in the example previously provided was that it was
> probably best to have the main object's DAO loop over and call each of the
> sub object's DAO individually.
Yes, or even not have separate DAOs for the subobjects. If they only
exist inside the composite object and have no relevance to anything
else, there's no real need to create a separate DAO for them (since
you are persisting them as part of the composite DAO already).
KISS / YAGNI would favor having a single DAO for the composite object,
only introducing subobject DAOs through refactoring *if* they needed
to be exposed in the future.
--
Sean A Corfield -- http://corfield.org/
Team Fusebox -- http://fusebox.org/
Got Gmail? -- I have 50, yes 50, invites to give away!
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]