You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Dan Allen <da...@mojavelinux.com> on 2003/03/10 23:09:10 UTC

peer design to generate list

Assume that I have a member database with 3 different tables, one
for members, one for companies and one for addresses.  I want to
display a list that is something like

Member Name     Company     Phone/Fax   E-mail

Naturally I would want to prepare an ArrayList of member objects to
be iterated on in my view.  I would start with (using torque's
DAO model)

List members = MemberPeer.doSelectAll();

Naturally in my view I could so something like:

<logic:iterate id="member" name="members">
    <bean:write name="employee" property="fullName"/>
    <bean:write name="employee" property="???"/>
    <bean:write name="employee" property="???"/>
    <bean:write name="employee" property="emailAddress"/>
</logic:iterate>

But as you can see, I am stuck on something.  How would I reach into
the Company table to get the company information and how could I be
sure I wasn't having to requery the database for every single member
to get this information (naturally the getCompany() method in the
member would get the link, but then it would have to requery for
that one member)?

I would start by adding a join I guess in the doSelectAll().  I
guess my question is, people say to leave the implementation of the
business logic out of the Action (assuming we are using struts),
which would mean no Criteria objects in the Action.  So who owns
this criteria to add the depenencies on the company table (or
address if we choose to show it?)

Dan

-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Daniel Allen, <da...@mojavelinux.com>
http://www.mojavelinux.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Microsoft's Law of Software Engineering: 
Don't worry if it doesn't work right. 
If everything did, we'd be out of a job.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -