Using DAO and DTO, or changing Patterns

I have been working on a web project that revolves around scheduling events and enrolling people is said events. The schema is fairly straight forward, but does not lend itself well to OO, or at least what I have been used to. Before I get to the questions, I'll layout the basic idea of the trouble part of the schema.

An Event has a 1:m relationship to Time Slots.

A Time Slot has a 1:m relationship to Participants.

A Time Slot also has a 1:M relationship to Tables.

So, a given Event can run in multiple Time Slots, have multiple Participants in a Time Slot, and occupy multiple Tables in a Time Slot.

Now, here's where I'd love some input because I know I'm lacking the experience. I've been reading in the forums here and in my books, many of which are included in the "must have" category as I've been reading here. I've adopted the DAO Pattern with DTOs the encompass the Event as a primary object/class. It has Lists which will get populated with the children. However, technically the way the schema is modelled, you cannot have participants or tables without a time slot. So, would I create separate bean or DTO to model the time slot that would also contains Lists for participants and tables? I imagine trying to represent nested relationships like the to a business layer might get hairy to maintain.

So, in one scenario, an administrator would like to update event details, I'd use a findById() method to retrieve the full depth of the relationship in the schema.

In a second scenario, a report is needed to list events, their times slots and tables in each time slot. Now, I have a List in my DTO that really has no need to be populated and would be wasteful to bring back from the database.

A third scenario is a user comes to the site and wishes to search for events that they could enroll in. This time, for the search, I just want a few pieces from the primary table to displayed, I don't want to get the whole of the nested relationships and I want to get the search results by time slot. So, the way I've modelled the first DTO is now pretty much useless.

So, is it better to construct to separate DTOs? I know I'd need different find() methods to support scenario 1 and 3. And in the case of retrieving non-needed data in scenario 2, should I provide a way to tell the DAO not to retrieve participants or just create yet another find() method that just doesn't populate participants?

While I do have a say in the schema, I cannot just up and change it. I am more than willing to hear any and all critiques on code, schema, and how any part of this is implemented. As far as questions to why I'm not using Spring, Hibernate, or X framework, I just haven't had time to review them, but as this is still in design, it's fair game.

Thanks in advance.

[2861 byte] By [zyphosa] at [2007-10-3 1:08:15]
# 1

>

> So, in one scenario, an administrator would like to

> update event details, I'd use a findById() method to

> retrieve the full depth of the relationship in the

> schema.

>

> In a second scenario, a report is needed to list

> events, their times slots and tables in each time

> slot. Now, I have a List in my DTO that really has

> no need to be populated and would be wasteful to

> bring back from the database.

>

Ok - so don't do it.

> A third scenario is a user comes to the site and

> wishes to search for events that they could enroll

> in. This time, for the search, I just want a few

> pieces from the primary table to displayed, I don't

> want to get the whole of the nested relationships and

> I want to get the search results by time slot. So,

> the way I've modelled the first DTO is now pretty

> much useless.

>

You can have more than one DTO. Or just don't populate everything in some cases.

jschella at 2007-7-14 18:05:02 > top of Java-index,Other Topics,Patterns & OO Design...