Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Child Records - When to load?

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Say I've got two tables with matching Java Beans. We'll call them Order and OrderItem. The Order bean contains a Collection which holds all OrderItem beans of that order which is modeled in the DB as a One to Many.
My question is should not the developer know exactly when they will need only the Order bean and when they will need both the Order and OrderBean collection populated? Loaded the Order bean with the Collection populated is an added cost and if I do not yet need it, why do it?
The reason I ask is we are currently reevaluating how our DB access should be handled. One of the leading candidates is a tool that determines when to load the children for you. So, if I only load the Order, the OrderItem Collection will not be populated until I try to access it (I can also force an init of the Collection which will do this). Since this 'hides' when the data is loaded and there is no longer a need for an explicit load of this data, I wonder if this is good practice. If I load an Order in a Servlet and forward to a JSP which shows the OrderItem collection, this method of loading the children will do it for us at the JSP level, which breaks the strict MVC (JSP being the View) model.
Any opinions and comments are requested.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic