Brian or anyone else,

I've come to a bit of a stumbling block when working on this extended DAO
model which has gotten me a little confused. It comes when trying to figure
out my create() method inside my sub class DAO. The idea we talked about
below would be to pass in the object which is to be persisted into the
create() method of my sub class object, and then at the top of the method
run SUPER.create(ARGUMENTS.SubObject) before running my standard create
query.

Now the problem with this arises in the fact when I create an entry in my
sub classes table, I need to know the ID of the freshly made entry in my
super classes table, so as to establish their relationship. Now I could do
this in my super classes create() method, by having it return the ID for the
entry it just created, however this does feel a little unusual, mainly
because I'm not used to working with super objects, is that the correct way
to handle it or is there a better way which I can't see?

Thanks again chaps,

R

-----Original Message-----
From: Robert Rawlins - Think Blue
[mailto:[EMAIL PROTECTED] 
Sent: 09 October 2007 21:50
To: CF-Talk
Subject: RE: CFC Composition and/or Extention

Oooh! Nice concept Brian, I hadn't thought about extending DAO's like
that...I like it ....a lot.

I now knight thee, Brian The Brain Kotek

Thanks mate,

Rob

-----Original Message-----
From: Brian Kotek [mailto:[EMAIL PROTECTED] 
Sent: 09 October 2007 18:25
To: CF-Talk
Subject: Re: CFC Composition and/or Extention

I would follow the same subtype/supertype idiom in your DAO objects. Have an
abstract MediaDAO which handles all the database interaction for the Media
table, and have concrete subtypes for each type of Media (VideoDAO,
ImageDAO, etc.) so that they can handle their own type-specific data. I
would have the concrete DAOs first run something like super.insert(data) so
that the superclass will handle whatever has to happen with the Media table,
and then they can go on doing their own type-specific database interactions
with their own tables.

On 10/9/07, Robert Rawlins - Think Blue
<[EMAIL PROTECTED]>
wrote:
>
> Thanks again Brian, another great reply,
>
> Yes these will defiantly be staying as a cast type, i.e. a image will
> always
> be an image and nothing more so at the moment I think the extended super
> class kind of makes good sense for me, taking a base Media object with the
> common attributes and extending it to the other sub classes which contain
> individual/unique properties. I then keep control over the whole lot with
> a
> service.
>
> One other thing I am wondering is how to organise my DAO's for this,
> should
> the Media class have its own DAO separate from the sub types? Or should
> the
> DAO's for my sub types deal with the media table as well as their own? I'm
> guessing the former, so that in my service saveImage() method it passes
> the
> super inited Image object to both the MediaDAO and the ImageDAO and they
> can
> just suck out the properties they need to persist it. Does that sound like
> the best option?
>
> Thanks again mate,
>
> Rob
>
>






~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Check out the new features and enhancements in the
latest product release - download the "What's New PDF" now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290723
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to