Hi, I have a basic design-level question to ask of those who are
using the struts framework. The question concerns how data from
the database get retrieved into the 'web-tier' beans
of the application when table joins are involved.

One approach is to nest objects. e.g. say we want to display
all the BANANA records belonging to each MONKEY in our database.

we can create a Monkey object and assign a list of Banana objects
to each Monkey.

public class Monkey {
  private String name;
  private List bananas; //type of objects in list is Banana

  public String getName() { return name; }
  public void setName(String name) { this.name = name; }
  public List getBananas() { return bananas; }
  public void setBananas(List bananas) { this.bananas = bananas; }
}

public class Banana {
  private String id;
  public String getId() { return id; }
  public void setId(String id) { this.id = id; }
}

This approach implies using the nested taglibs package. It has
potential downside that many objects get created.

Another approach is to create a 'super' object to aggregate the
data for the join between tables. e.g.

public class MonkeyBanana {
  private String name; //Monkey name
  private String id; //Banana id;
}

This is essentially a denormalization of the Monkey and Banana
objects. It is more redundant, but we don't need to use the
nested taglib package and we create fewer objects.

Does anyone have advice regarding which approach is better?

Vlad






_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com


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

Reply via email to