Sometimes the simplest answer is the best... and even when it isn't the
best, it's *still* simple :) ...

How about just creating a new DAO/DTO that only contains the data you need?

It would be a duplication to a degree, but that's not *always* an
absolutely evil thing... especially since it sounds like the new A object
you want to display on the page may not truly model a real domain object
(where they others I presume are) but is instead something of a hybrid, I
could personally live with this.

Either that, or I would just create a single Miscellaneous DAO that has
methods that don't *quite* fit in other DAOs... maybe this is one of
them... then you would still have a DTO for this particular case, and a
new one for each particular case in the DAO, if any more came up.

FYI, most of my apps have the true DAO/DTOs, but they all also have such a
miscellaneous class for handling things exactly like this.  There tend to
be very few such cases, but they do come up, and I find this to be a nice
way to organize them.  In fact, in a couple of cases I've decided to make
the DTOs inner classes of the DAO, just to make it obvious they are
related and probably limited in their use cases.

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Thu, August 18, 2005 8:00 am, Tom Ziemer said:
> Hi everybody!
>
> In my app, I am using DAOs/DTOs to perform CRUD operations on a legacy
> database packed with lots of triggers and stored procedures. Some of my
> DTOs are pretty complex, meaning, they have to be assembled from many
> tables.
>
> A simple example:
> Object a (loaded by aDAO) has a list of b objects (loaded by bDAO),
> which in turn has a list of c objects (loaded by cDAO)
>
> The problem:
> In my struts-based webapp, I want to display some a objects on a page
> (the objects won't be used after that anymore). I need a few attributes
> from related object b but nothing at all from the related c objects.
> When I use my aDAO to retrieve my a objects, this will cause a large
> number of sql queries (1 per object), resulting in lots of data I do not
> need.
>
> The question:
> Wouldn't it be more effecient to use a single query, that only loads the
> required data? This would mean though, that I cannot use my DTOs.
>
> Any thoughts?
>
> Regards,
> Tom
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to