• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Managable Object mapping

 
Rick Smith
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • 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.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic