• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Managable Object mapping

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a database that, amongst other things has a table which represents relationships between a record, and other record of the same table.

The obvious way to map this structure to a domain model is to have an object representing the record - e.g MyMainObject, which has a List<MyMainObject> attribute to provided it's related objects.

I can see a problem with this approach, while in many cases when I deal with a MyMainObject object I would expect to have it's related item list populated how far does this mapping go. If the database had a large number of relations represented would the mapping return all the records directly related to the one I am retrieving, AND all the records related to those, I could see the scenario where a significant portion of the database is retrieved!


Is this a common problem with ORM or is it possibly down to a weak domain model, or database structure?

Any oppinions or guidance are greatfully recived.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


If the database had a large number of relations represented would the mapping return all the records directly related to the one I am retrieving, AND all the records related to those, I could see the scenario where a significant portion of the database is retrieved!


Most ORM's implement a lazy initialisation mechanism for related entitites. Taking Hibernate as an example, you parent object could contain a list of proxy child objects. Have a read of this.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic