views:

42

answers:

0

While I'll go for the Ghost pattern in a 1:1 relationship, I'm not sure if this is sufficient in a 1:n relationship.

For example, when I load an Order object that may have a hundred Item objects, I would first assign NULL to the items property.

The question is:

A) Should I assign NULL and then, upon first access of the items property look for ALL orders of that item and load ALL of them?

B) Or should I load only a lightweight record set containing only all the order_id's and load 100 Item Ghost objects which only have the order_id set, but everything else NULL - and as soon as an Item object is accessed to fetch more details from it, lazy-load that specific Item object data?